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

Commit 6f158ef7 authored by Thomas Stuart's avatar Thomas Stuart
Browse files

transactional video state changes

changes:
- transactional calls do not need to add
  CallAttributes#SUPPORTS_VIDEO_CALLING in order to initiate
  a video call Or change the video state
- The CallAttributes#CallType is remapped in the
  Outgoing/Incoming-CallTransaction to a VideoProfile value

While investigating transactional video call behavior, I noticed that
the CallAttributes#AUDIO_CALL is remapped to VideoProfile#STATE_TX_ENABLED.
Now, when transactional calls are created, the video value is correctly
mapped to the equalivalent VideoProfile value.

Additionally, the video state changes should not be gatted by the
CallAttributes#SUPPORTS_VIDEO_CALLING. Core-Telecom will not have access
to the new flagged capability so for now, video state changes on a per
call basis will not be gated by that capability.

Flag: com.android.server.telecom.flags.transactional_video_state
Fixes: 335887238 (remap CallAttributes CallType in addCall)
Fixes: 325320195 (do not gate setVideoState with capability)
Test:  4 new unit tests, removed 1 CTS test
Change-Id: I04b030db864e00370e45510670c2e99b6bdfd9ff
parent 3f0e10aa
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 com.android.server.telecom;

import static com.android.server.telecom.voip.VideoStateTranslation.TransactionalVideoStateToString;

import android.telecom.Log;

public class CachedVideoStateChange implements CachedCallback {
    public static final String ID = CachedVideoStateChange.class.getSimpleName();
    int mCurrentVideoState;

    public int getCurrentCallEndpoint() {
        return mCurrentVideoState;
    }

    public CachedVideoStateChange(int videoState) {
        mCurrentVideoState = videoState;
    }

    @Override
    public void executeCallback(CallSourceService service, Call call) {
        service.onVideoStateChanged(call, mCurrentVideoState);
        Log.addEvent(call, LogUtils.Events.VIDEO_STATE_CHANGED,
                TransactionalVideoStateToString(mCurrentVideoState));
    }

    @Override
    public String getCallbackId() {
        return ID;
    }

    @Override
    public int hashCode() {
        return mCurrentVideoState;
    }

    @Override
    public boolean equals(Object obj){
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof CachedVideoStateChange other)) {
            return false;
        }
        return mCurrentVideoState == other.mCurrentVideoState;
    }
}
+15 −13
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.telecom;
import static android.provider.CallLog.Calls.MISSED_REASON_NOT_MISSED;
import static android.telephony.TelephonyManager.EVENT_DISPLAY_EMERGENCY_MESSAGE;

import static com.android.server.telecom.voip.VideoStateTranslation.TransactionalVideoStateToString;
import static com.android.server.telecom.voip.VideoStateTranslation.VideoProfileStateToTransactionalVideoState;

import android.annotation.NonNull;
@@ -4114,14 +4115,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            videoState = VideoProfile.STATE_AUDIO_ONLY;
        }

        // Transactional calls have the ability to change video calling capabilities on a per-call
        // basis as opposed to ConnectionService calls which are only based on the PhoneAccount.
        if (mFlags.transactionalVideoState()
                && mIsTransactionalCall && !mTransactionalCallSupportsVideoCalling) {
            Log.i(this, "setVideoState: The transactional does NOT support video calling."
                    + " defaulted to audio (video not supported)");
            videoState = VideoProfile.STATE_AUDIO_ONLY;
        }
        // TODO:: b/338280297. If a transactional call does not have the
        //   CallAttributes.SUPPORTS_VIDEO_CALLING capability, the videoState should be set to audio

        // Track Video State history during the duration of the call.
        // Only update the history when the call is active or disconnected. This ensures we do
@@ -4138,17 +4133,24 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        int previousVideoState = mVideoState;
        mVideoState = videoState;
        if (mVideoState != previousVideoState) {
            if (!mIsTransactionalCall) {
                Log.addEvent(this, LogUtils.Events.VIDEO_STATE_CHANGED,
                        VideoProfile.videoStateToString(videoState));
            }
            for (Listener l : mListeners) {
                l.onVideoStateChanged(this, previousVideoState, mVideoState);
            }
        }

        if (mFlags.transactionalVideoState()
                && mIsTransactionalCall && mTransactionalService != null) {
        if (mFlags.transactionalVideoState() && mIsTransactionalCall) {
            int transactionalVS = VideoProfileStateToTransactionalVideoState(mVideoState);
            if (mTransactionalService != null) {
                Log.addEvent(this, LogUtils.Events.VIDEO_STATE_CHANGED,
                        TransactionalVideoStateToString(transactionalVS));
                mTransactionalService.onVideoStateChanged(this, transactionalVS);
            } else {
                cacheServiceCallback(new CachedVideoStateChange(transactionalVS));
            }
        }

        if (VideoProfile.isVideo(videoState)) {
+2 −0
Original line number Diff line number Diff line
@@ -35,4 +35,6 @@ public interface CallSourceService {
    void onCallEndpointChanged(Call activeCall, CallEndpoint callEndpoint);

    void onAvailableCallEndpointsChanged(Call activeCall, Set<CallEndpoint> availableCallEndpoints);

    void onVideoStateChanged(Call activeCall, int videoState);
}
+5 −0
Original line number Diff line number Diff line
@@ -1987,6 +1987,11 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        }
    }

    @Override
    public void onVideoStateChanged(Call call, int videoState){
        // pass through. ConnectionService does not implement this method.
    }

    /** @see IConnectionService#onMuteStateChanged(String, boolean, Session.Info) */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
    @Override
+2 −2
Original line number Diff line number Diff line
@@ -215,11 +215,11 @@ public class TelecomServiceImpl {
                switch (callAttributes.getDirection()) {
                    case DIRECTION_OUTGOING:
                        transaction = new OutgoingCallTransaction(callId, mContext, callAttributes,
                                mCallsManager, extras);
                                mCallsManager, extras, mFeatureFlags);
                        break;
                    case DIRECTION_INCOMING:
                        transaction = new IncomingCallTransaction(callId, callAttributes,
                                mCallsManager, extras);
                                mCallsManager, extras, mFeatureFlags);
                        break;
                    default:
                        throw new IllegalArgumentException(String.format("Invalid Call Direction. "
Loading