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

Commit bc220b89 authored by Grant Menke's avatar Grant Menke Committed by Android (Google) Code Review
Browse files

Merge "Ensure the associated call count is accurately tracked for RCS." into main

parents bd0d6d8f 45c65d16
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -36,7 +36,8 @@ aconfig_declarations {
      "telecom_calllog_flags.aconfig",
      "telecom_resolve_hidden_dependencies.aconfig",
      "telecom_bluetoothroutemanager_flags.aconfig",
      "telecom_work_profile_flags.aconfig"
      "telecom_work_profile_flags.aconfig",
      "telecom_connection_service_wrapper_flags.aconfig",
    ],
}
+8 −0
Original line number Diff line number Diff line
package: "com.android.server.telecom.flags"

flag {
  name: "updated_rcs_call_count_tracking"
  namespace: "telecom"
  description: "Ensure that the associatedCallCount of CS and RCS is accurately being tracked."
  bug: "286154316"
}
 No newline at end of file
+45 −6
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telecom.IVideoProvider;
import com.android.internal.util.Preconditions;
import com.android.server.telecom.flags.FeatureFlags;
import com.android.server.telecom.flags.Flags;
import com.android.server.telecom.stats.CallFailureCause;
import com.android.server.telecom.stats.CallStateChangedAtomWriter;
import com.android.server.telecom.ui.ToastFactory;
@@ -437,6 +438,13 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    private int mCallerDisplayNamePresentation;

    /**
     * The remote connection service which is attempted or already connecting this call. This is set
     * to a non-null value only when a connection manager phone account is in use. When set, this
     * will correspond to the target phone account of the {@link Call}.
     */
    private ConnectionServiceWrapper mRemoteConnectionService;

    /**
     * The connection service which is attempted or already connecting this call.
     */
@@ -2364,11 +2372,25 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,

    @VisibleForTesting
    public void setConnectionService(ConnectionServiceWrapper service) {
        setConnectionService(service, null);
    }

    @VisibleForTesting
    public void setConnectionService(
            ConnectionServiceWrapper service,
            ConnectionServiceWrapper remoteService
    ) {
        Preconditions.checkNotNull(service);

        clearConnectionService();

        service.incrementAssociatedCallCount();

        if (mFlags.updatedRcsCallCountTracking() && remoteService != null) {
            remoteService.incrementAssociatedCallCount();
            mRemoteConnectionService = remoteService;
        }

        mConnectionService = service;
        mAnalytics.setCallConnectionService(service.getComponentName().flattenToShortString());
        mConnectionService.addCall(this);
@@ -2376,10 +2398,12 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,

    /**
     * Perform an in-place replacement of the {@link ConnectionServiceWrapper} for this Call.
     * Removes the call from its former {@link ConnectionServiceWrapper}, ensuring that the
     * ConnectionService is NOT unbound if the call count hits zero.
     * This is used by the {@link ConnectionServiceWrapper} when handling {@link Connection} and
     * {@link Conference} additions via a ConnectionManager.
     * Removes the call from its former {@link ConnectionServiceWrapper}, while still ensuring the
     * former {@link ConnectionServiceWrapper} is tracked as the mRemoteConnectionService for this
     * call so that the associatedCallCount of that {@link ConnectionServiceWrapper} is accurately
     * tracked until it is supposed to be unbound.
     * This method is used by the {@link ConnectionServiceWrapper} when handling {@link Connection}
     * and {@link Conference} additions via a ConnectionManager.
     * The original {@link android.telecom.ConnectionService} will directly add external calls and
     * conferences to Telecom as well as the ConnectionManager, which will add to Telecom.  In these
     * cases since its first added to via the original CS, we want to change the CS responsible for
@@ -2392,10 +2416,19 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,

        if (mConnectionService != null) {
            ConnectionServiceWrapper serviceTemp = mConnectionService;

            if (mFlags.updatedRcsCallCountTracking()) {
                // Continue to track the former CS for this call so that it doesn't unbind early:
                mRemoteConnectionService = serviceTemp;
            }

            mConnectionService = null;
            serviceTemp.removeCall(this);

            if (!mFlags.updatedRcsCallCountTracking()) {
                serviceTemp.decrementAssociatedCallCount(true /*isSuppressingUnbind*/);
            }
        }

        service.incrementAssociatedCallCount();
        mConnectionService = service;
@@ -2408,6 +2441,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    void clearConnectionService() {
        if (mConnectionService != null) {
            ConnectionServiceWrapper serviceTemp = mConnectionService;
            ConnectionServiceWrapper remoteServiceTemp = mRemoteConnectionService;
            mRemoteConnectionService = null;
            mConnectionService = null;
            serviceTemp.removeCall(this);

@@ -2418,6 +2453,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            // necessary, but cleaning up mConnectionService prior to triggering an unbind is good
            // to do.
            decrementAssociatedCallCount(serviceTemp);

            if (mFlags.updatedRcsCallCountTracking() && remoteServiceTemp != null) {
                decrementAssociatedCallCount(remoteServiceTemp);
            }
        }
    }

@@ -2436,7 +2475,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            return;
        }
        mCreateConnectionProcessor = new CreateConnectionProcessor(this, mRepository, this,
                phoneAccountRegistrar, mContext);
                phoneAccountRegistrar, mContext, mFlags);
        mCreateConnectionProcessor.process();
    }

+4 −2
Original line number Diff line number Diff line
@@ -5844,7 +5844,8 @@ public class CallsManager extends Call.ListenerBase
            return;
        }
        ConnectionServiceWrapper service = mConnectionServiceRepository.getService(
                phoneAccountHandle.getComponentName(), phoneAccountHandle.getUserHandle());
                phoneAccountHandle.getComponentName(), phoneAccountHandle.getUserHandle(),
                mFeatureFlags);
        if (service == null) {
            Log.i(this, "Found no connection service.");
            return;
@@ -5869,7 +5870,8 @@ public class CallsManager extends Call.ListenerBase
            return;
        }
        ConnectionServiceWrapper service = mConnectionServiceRepository.getService(
                phoneAccountHandle.getComponentName(), phoneAccountHandle.getUserHandle());
                phoneAccountHandle.getComponentName(), phoneAccountHandle.getUserHandle(),
                mFeatureFlags);
        if (service == null) {
            Log.i(this, "Found no connection service.");
            return;
+7 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.util.Pair;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.telecom.flags.FeatureFlags;

import java.util.HashMap;

@@ -61,7 +62,10 @@ public class ConnectionServiceRepository {
    }

    @VisibleForTesting
    public ConnectionServiceWrapper getService(ComponentName componentName, UserHandle userHandle) {
    public ConnectionServiceWrapper getService(
            ComponentName componentName,
            UserHandle userHandle,
            FeatureFlags featureFlags) {
        Pair<ComponentName, UserHandle> cacheKey = Pair.create(componentName, userHandle);
        ConnectionServiceWrapper service = mServiceCache.get(cacheKey);
        if (service == null) {
@@ -72,7 +76,8 @@ public class ConnectionServiceRepository {
                    mCallsManager,
                    mContext,
                    mLock,
                    userHandle);
                    userHandle,
                    featureFlags);
            service.addListener(mUnbindListener);
            mServiceCache.put(cacheKey, service);
        }
Loading