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

Commit ba776691 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11367679 from ce751124 to 24Q2-release

Change-Id: Idaf76d3c9335b065be78ad5fc0ef1f35d0afef6f
parents 60766061 ce751124
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -14,13 +14,6 @@ flag {
  bug: "301713560"
}

flag {
  name: "unbind_timeout_connections"
  namespace: "telecom"
  description: "When set, Telecom will auto-unbind if a ConnectionService returns no connections after some time."
  bug: "293458004"
}

flag{
  name: "add_call_uri_for_missed_calls"
  namespace: "telecom"
+29 −19
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import android.location.CountryDetector;
import android.location.Location;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.Looper;
import android.os.UserHandle;
import android.os.PersistableBundle;
@@ -57,6 +59,8 @@ import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.stream.Stream;

/**
@@ -116,8 +120,10 @@ public final class CallLogManager extends CallsManagerListenerBase {
    private static final String CALL_TYPE = "callType";
    private static final String CALL_DURATION = "duration";

    private Object mLock;
    private final Object mLock = new Object();
    private Country mCurrentCountry;
    private String mCurrentCountryIso;
    private HandlerExecutor mCountryCodeExecutor;

    private final FeatureFlags mFeatureFlags;

@@ -130,7 +136,7 @@ public final class CallLogManager extends CallsManagerListenerBase {
        mPhoneAccountRegistrar = phoneAccountRegistrar;
        mMissedCallNotifier = missedCallNotifier;
        mAnomalyReporterAdapter = anomalyReporterAdapter;
        mLock = new Object();
        mCountryCodeExecutor = new HandlerExecutor(new Handler(Looper.getMainLooper()));
        mFeatureFlags = featureFlags;
    }

@@ -620,7 +626,7 @@ public final class CallLogManager extends CallsManagerListenerBase {
            return Locale.getDefault().getCountry();
        }

        return country.getCountryIso();
        return country.getCountryCode();
    }

    /**
@@ -631,32 +637,36 @@ public final class CallLogManager extends CallsManagerListenerBase {
    public String getCountryIso() {
        synchronized (mLock) {
            if (mCurrentCountryIso == null) {
                Log.i(TAG, "Country cache is null. Detecting Country and Setting Cache...");
                // Moving this into the constructor will pose issues if the service is not yet set
                // up, causing a RemoteException to be thrown. Note that the callback is only
                // registered if the country iso cache is null (so in an ideal setting, this should
                // only require a one-time configuration).
                final CountryDetector countryDetector =
                        (CountryDetector) mContext.getSystemService(Context.COUNTRY_DETECTOR);
                Country country = null;
                if (countryDetector != null) {
                    country = countryDetector.detectCountry();
                    countryDetector.registerCountryDetectorCallback(
                            mCountryCodeExecutor, this::countryCodeConsumer);
                }
                mCurrentCountryIso = getCountryIsoFromCountry(mCurrentCountry);
            }
            return mCurrentCountryIso;
        }
    }

                    countryDetector.addCountryListener((newCountry) -> {
                        Log.startSession("CLM.oCD");
    /** Consumer to receive the country code if it changes. */
    private void countryCodeConsumer(Country newCountry) {
        Log.startSession("CLM.cCC");
        try {
                            synchronized (mLock) {
            Log.i(TAG, "Country ISO changed. Retrieving new ISO...");
            synchronized (mLock) {
                mCurrentCountry = newCountry;
                mCurrentCountryIso = getCountryIsoFromCountry(newCountry);
            }
        } finally {
            Log.endSession();
        }
                    }, Looper.getMainLooper());
                }
                mCurrentCountryIso = getCountryIsoFromCountry(country);
            }
            return mCurrentCountryIso;
        }
    }


    /**
     * Returns a pair containing the number of rows in the call log, as well as the maximum call log
     * ID.  There is a limit of 500 entries in the call log for a phone account, so once we hit 500
+4 −47
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.UserHandle;
@@ -73,14 +74,13 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.Objects;

/**
 * Wrapper for {@link IConnectionService}s, handles binding to {@link IConnectionService} and keeps
@@ -93,12 +93,9 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        ConnectionServiceFocusManager.ConnectionServiceFocus {

    private static final String TELECOM_ABBREVIATION = "cast";
    private static final long SERVICE_BINDING_TIMEOUT = 15000L;
    private CompletableFuture<Pair<Integer, Location>> mQueryLocationFuture = null;
    private @Nullable CancellationSignal mOngoingQueryLocationRequest = null;
    private final ExecutorService mQueryLocationExecutor = Executors.newSingleThreadExecutor();
    private ScheduledExecutorService mScheduledExecutor =
            Executors.newSingleThreadScheduledExecutor();

    private final class Adapter extends IConnectionServiceAdapter.Stub {

@@ -1603,22 +1600,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                        .setParticipants(call.getParticipants())
                        .setIsAdhocConferenceCall(call.isAdhocConferenceCall())
                        .build();
                if (Flags.unbindTimeoutConnections()) {
                    android.telecom.Logging.Runnable r =
                            new android.telecom.Logging.Runnable("CSW.cC", mLock) {
                        @Override
                        public void loggedRun() {
                            if (!call.isCreateConnectionComplete()) {
                                Log.e(this, new Exception(), "Conference %s creation timeout",
                                        getComponentName());
                                response.handleCreateConferenceFailure(
                                        new DisconnectCause(DisconnectCause.ERROR));
                            }
                        }
                    };
                    mScheduledExecutor.schedule(r.getRunnableToCancel(), SERVICE_BINDING_TIMEOUT,
                            TimeUnit.MILLISECONDS);
                }
                try {
                    mServiceInterface.createConference(
                            call.getConnectionManagerPhoneAccount(),
@@ -1659,7 +1640,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                    Log.i(ConnectionServiceWrapper.this, "Call not present"
                            + " in call id mapper, maybe it was aborted before the bind"
                            + " completed successfully?");

                    response.handleCreateConnectionFailure(
                            new DisconnectCause(DisconnectCause.CANCELED));
                    return;
@@ -1720,24 +1700,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                        .setRttPipeFromInCall(call.getInCallToCsRttPipeForCs())
                        .setRttPipeToInCall(call.getCsToInCallRttPipeForCs())
                        .build();

                if (Flags.unbindTimeoutConnections()) {
                    android.telecom.Logging.Runnable r =
                            new android.telecom.Logging.Runnable("CSW.cC", mLock) {
                                @Override
                                public void loggedRun() {
                                    if (!call.isCreateConnectionComplete()) {
                                        Log.e(this, new Exception(),
                                                "Connection %s creation timeout",
                                                getComponentName());
                                        response.handleCreateConnectionFailure(
                                                new DisconnectCause(DisconnectCause.ERROR));
                                    }
                                }
                            };
                    mScheduledExecutor.schedule(r.getRunnableToCancel(), SERVICE_BINDING_TIMEOUT,
                            TimeUnit.MILLISECONDS);
                }
                try {
                    mServiceInterface.createConnection(
                            call.getConnectionManagerPhoneAccount(),
@@ -1746,6 +1708,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                            call.shouldAttachToExistingConnection(),
                            call.isUnknown(),
                            Log.getExternalSession(TELECOM_ABBREVIATION));

                } catch (RemoteException e) {
                    Log.e(this, e, "Failure to createConnection -- %s", getComponentName());
                    mPendingResponses.remove(callId).handleCreateConnectionFailure(
@@ -2194,8 +2157,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        }
    }

    @VisibleForTesting
    public void addCall(Call call) {
    void addCall(Call call) {
        if (mCallIdMapper.getCallId(call) == null) {
            mCallIdMapper.addCall(call);
        }
@@ -2663,9 +2625,4 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        sb.append("]");
        return sb.toString();
    }

    @VisibleForTesting
    public void setScheduledExecutorService(ScheduledExecutorService service) {
        mScheduledExecutor = service;
    }
}
+7 −5
Original line number Diff line number Diff line
@@ -156,25 +156,26 @@ public class EmergencyCallDiagnosticLogger extends CallsManagerListenerBase
        List<Integer> dataCollectionTypes = getDataCollectionTypes(reason);
        boolean invokeTelephonyPersistApi = false;
        CallEventTimestamps ts = mEmergencyCallsMap.get(call);
        EmergencyCallDiagnosticParams dp =
                new EmergencyCallDiagnosticParams();
        EmergencyCallDiagnosticParams.Builder callDiagnosticBuilder =
                new EmergencyCallDiagnosticParams.Builder();
        for (Integer dataCollectionType : dataCollectionTypes) {
            switch (dataCollectionType) {
                case COLLECTION_TYPE_TELECOM_STATE:
                    if (isTelecomDumpCollectionEnabled()) {
                        dp.setTelecomDumpSysCollection(true);
                        callDiagnosticBuilder.setTelecomDumpSysCollectionEnabled(true);
                        invokeTelephonyPersistApi = true;
                    }
                    break;
                case COLLECTION_TYPE_TELEPHONY_STATE:
                    if (isTelephonyDumpCollectionEnabled()) {
                        dp.setTelephonyDumpSysCollection(true);
                        callDiagnosticBuilder.setTelephonyDumpSysCollectionEnabled(true);
                        invokeTelephonyPersistApi = true;
                    }
                    break;
                case COLLECTION_TYPE_LOGCAT_BUFFERS:
                    if (isLogcatCollectionEnabled()) {
                        dp.setLogcatCollection(true, ts.getCallCreatedTime());
                        callDiagnosticBuilder.setLogcatCollectionStartTimeMillis(
                                ts.getCallCreatedTime());
                        invokeTelephonyPersistApi = true;
                    }
                    break;
@@ -191,6 +192,7 @@ public class EmergencyCallDiagnosticLogger extends CallsManagerListenerBase
                default:
            }
        }
        EmergencyCallDiagnosticParams dp = callDiagnosticBuilder.build();
        if (invokeTelephonyPersistApi) {
            mAsyncTaskExecutor.execute(new Runnable() {
                @Override
+0 −2
Original line number Diff line number Diff line
@@ -1035,7 +1035,6 @@ public class BasicCallTests extends TelecomSystemTest {
        call.setTargetPhoneAccount(mPhoneAccountA1.getAccountHandle());
        assert(call.isVideoCallingSupportedByPhoneAccount());
        assertEquals(VideoProfile.STATE_BIDIRECTIONAL, call.getVideoState());
        call.setIsCreateConnectionComplete(true);
    }

    /**
@@ -1059,7 +1058,6 @@ public class BasicCallTests extends TelecomSystemTest {
        call.setTargetPhoneAccount(mPhoneAccountA2.getAccountHandle());
        assert(!call.isVideoCallingSupportedByPhoneAccount());
        assertEquals(VideoProfile.STATE_AUDIO_ONLY, call.getVideoState());
        call.setIsCreateConnectionComplete(true);
    }

    /**
Loading