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

Commit d5c78beb authored by Brad Ebinger's avatar Brad Ebinger Committed by Android (Google) Code Review
Browse files

Merge "Cache call events to ensure that cap exchange events are not missed" into main

parents 43398e00 3e883652
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -23,6 +23,17 @@ flag {
  bug: "321369729"
}

# OWNER=breadley TARGET=24Q4
flag {
  name: "cache_call_events"
  namespace: "telecom"
  description: "Cache call events to wait for the ServiceWrapper to be set"
  bug: "364311190"
  metadata {
      purpose: PURPOSE_BUGFIX
    }
}

# OWNER = breadley TARGET=24Q3
flag {
  name: "cancel_removal_on_emergency_redial"
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,11 @@ public class CachedAvailableEndpointsChange implements CachedCallback {
        mAvailableEndpoints = endpoints;
    }

    @Override
    public int getCacheType() {
        return TYPE_STATE;
    }

    @Override
    public void executeCallback(CallSourceService service, Call call) {
        service.onAvailableCallEndpointsChanged(call, mAvailableEndpoints);
+48 −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 android.os.Bundle;
import android.telecom.Log;

public class CachedCallEventQueue implements CachedCallback {
    public static final String ID = CachedCallEventQueue.class.getSimpleName();

    private final String mEvent;
    private final Bundle mExtras;

    public CachedCallEventQueue(String event, Bundle extras) {
        mEvent = event;
        mExtras = extras;
    }

    @Override
    public int getCacheType() {
        return TYPE_QUEUE;
    }

    @Override
    public void executeCallback(CallSourceService service, Call call) {
        Log.addEvent(call, LogUtils.Events.CALL_EVENT, mEvent);
        service.sendCallEvent(call, mEvent, mExtras);
    }

    @Override
    public String getCallbackId() {
        return ID;
    }
}
+33 −4
Original line number Diff line number Diff line
@@ -22,6 +22,27 @@ package com.android.server.telecom;
 * The callback will be executed once the service is set.
 */
public interface CachedCallback {

    /**
     * This callback is caching a state, meaning any new CachedCallbacks with the same
     * {@link #getCallbackId()} will REPLACE any existing CachedCallback.
     */
    int TYPE_STATE = 0;
    /**
     * This callback is caching a Queue, meaning that any new CachedCallbacks with the same
     * {@link #getCallbackId()} will enqueue as a FIFO queue and each instance of this
     * CachedCallback will run {@link #executeCallback(CallSourceService, Call)}.
     */
    int TYPE_QUEUE = 1;

    /**
     * This method allows the callback to determine whether it is caching a {@link #TYPE_STATE} or
     * a {@link #TYPE_QUEUE}.
     *
     * @return Either {@link #TYPE_STATE} or {@link #TYPE_QUEUE} based on the callback type.
     */
    int getCacheType();

    /**
     * This method executes the callback that was cached because the service was not available
     * at the time the callback was ready.
@@ -33,11 +54,19 @@ public interface CachedCallback {
    void executeCallback(CallSourceService service, Call call);

    /**
     * This method is helpful for caching the callbacks.  If the callback is called multiple times
     * while the service is not set, ONLY the last callback should be sent to the client since the
     * last callback is the most relevant
     * The ID that this CachedCallback should use to identify itself as a distinct operation.
     * <p>
     * If {@link #TYPE_STATE} is set for {@link #getCacheType()}, and a CachedCallback with the
     * same ID is called multiple times while the service is not set, ONLY the last callback will be
     * sent to the client since the last callback is the most relevant.
     * <p>
     * If {@link #TYPE_QUEUE} is set for {@link #getCacheType()} and the CachedCallback with the
     * same ID is called multiple times while the service is not set, each CachedCallback will be
     * enqueued in FIFO order. Once the service is set, {@link #executeCallback} will be called
     * for each CachedCallback with the same ID.
     *
     * @return the callback id that is used in a map to only store the last callback value
     * @return A unique callback id that will be used differentiate this CachedCallback type with
     * other CachedCallback types.
     */
    String getCallbackId();
}
+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,11 @@ public class CachedCurrentEndpointChange implements CachedCallback {
        mCurrentCallEndpoint = callEndpoint;
    }

    @Override
    public int getCacheType() {
        return TYPE_STATE;
    }

    @Override
    public void executeCallback(CallSourceService service, Call call) {
        service.onCallEndpointChanged(call, mCurrentCallEndpoint);
Loading