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

Commit 8a3b8221 authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge changes from topic "cp-att-rtt-switch"

am: c7ebe554

Change-Id: I3c94abd54d1b40da5f275c08472cdba4f8f7acdf
parents 200c3864 c7ebe554
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@ message TelecomLog {

  // Hardware revision (EVT, DVT, PVT etc.)
  optional string hardware_revision = 3;

  // Carrier ID that the device is associated to
  optional int32 carrier_id = 4;
}

message LogSessionTiming {
+30 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.telecom;

import android.content.Context;
import android.os.SystemProperties;

import android.telecom.Connection;
@@ -23,6 +24,8 @@ import android.telecom.DisconnectCause;
import android.telecom.Logging.EventManager;
import android.telecom.ParcelableCallAnalytics;
import android.telecom.TelecomAnalytics;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.util.Base64;
import android.telecom.Log;

@@ -37,10 +40,12 @@ import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.PriorityQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.stream.Collectors;
@@ -628,7 +633,7 @@ public class Analytics {
        return new TelecomAnalytics(sessionTimings, calls);
    }

    public static void dumpToEncodedProto(PrintWriter pw, String[] args) {
    public static void dumpToEncodedProto(Context context, PrintWriter pw, String[] args) {
        TelecomLogClass.TelecomLog result = new TelecomLogClass.TelecomLog();

        synchronized (sLock) {
@@ -642,6 +647,7 @@ public class Analytics {
                            .setTimeMillis(timing.getTime()))
                    .toArray(TelecomLogClass.LogSessionTiming[]::new);
            result.setHardwareRevision(SystemProperties.get("ro.boot.revision", ""));
            result.setCarrierId(getCarrierId(context));
            if (args.length > 1 && CLEAR_ANALYTICS_ARG.equals(args[1])) {
                sCallIdToInfo.clear();
                sSessionTimings.clear();
@@ -652,6 +658,29 @@ public class Analytics {
        pw.write(encodedProto);
    }

    private static int getCarrierId(Context context) {
        SubscriptionManager subscriptionManager =
                context.getSystemService(SubscriptionManager.class);
        List<SubscriptionInfo> subInfos = subscriptionManager.getActiveSubscriptionInfoList();
        if (subInfos == null) {
            return -1;
        }
        return subInfos.stream()
                .max(Comparator.comparing(Analytics::scoreSubscriptionInfo))
                .map(SubscriptionInfo::getCarrierId).orElse(-1);
    }

    // Copied over from Telephony's server-side logic for consistency
    private static int scoreSubscriptionInfo(SubscriptionInfo subInfo) {
        final int scoreCarrierId = 0b100;
        final int scoreNotOpportunistic = 0b010;
        final int scoreSlot0 = 0b001;

        return ((subInfo.getCarrierId() >= 0) ? scoreCarrierId : 0)
                + (subInfo.isOpportunistic() ? 0 : scoreNotOpportunistic)
                + ((subInfo.getSimSlotIndex() == 0) ? scoreSlot0 : 0);
    }

    public static void dump(IndentingPrintWriter writer) {
        synchronized (sLock) {
            int prefixLength = CallsManager.TELECOM_CALL_ID_PREFIX.length();
+23 −6
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.PersistableBundle;
import android.os.Process;
import android.os.SystemClock;
import android.os.SystemProperties;
@@ -1103,9 +1104,11 @@ public class CallsManager extends Call.ListenerBase
                call.setIsVoipAudioMode(true);
            }
        }
        if (isRttSettingOn() ||

        boolean isRttSettingOn = isRttSettingOn(phoneAccountHandle);
        if (isRttSettingOn ||
                extras.getBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT, false)) {
            Log.i(this, "Incoming call requesting RTT, rtt setting is %b", isRttSettingOn());
            Log.i(this, "Incoming call requesting RTT, rtt setting is %b", isRttSettingOn);
            call.createRttStreams();
            // Even if the phone account doesn't support RTT yet, the connection manager might
            // change that. Set this to check it later.
@@ -1536,11 +1539,12 @@ public class CallsManager extends Call.ListenerBase

                    boolean isVoicemail = isVoicemail(callToUse.getHandle(), accountToUse);

                    if (!isVoicemail && (isRttSettingOn() || (extras != null
                    boolean isRttSettingOn = isRttSettingOn(phoneAccountHandle);
                    if (!isVoicemail && (isRttSettingOn || (extras != null
                            && extras.getBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT,
                            false)))) {
                        Log.d(this, "Outgoing call requesting RTT, rtt setting is %b",
                                isRttSettingOn());
                                isRttSettingOn);
                        if (callToUse.isEmergencyCall() || (accountToUse != null
                                && accountToUse.hasCapabilities(PhoneAccount.CAPABILITY_RTT))) {
                            // If the call requested RTT and it's an emergency call, ignore the
@@ -2320,9 +2324,22 @@ public class CallsManager extends Call.ListenerBase
        mProximitySensorManager.turnOff(screenOnImmediately);
    }

    private boolean isRttSettingOn() {
        return Settings.Secure.getInt(mContext.getContentResolver(),
    private boolean isRttSettingOn(PhoneAccountHandle handle) {
        boolean isRttModeSettingOn = Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.RTT_CALLING_MODE, 0) != 0;
        // If the carrier config says that we should ignore the RTT mode setting from the user,
        // assume that it's off (i.e. only make an RTT call if it's requested through the extra).
        boolean shouldIgnoreRttModeSetting = getCarrierConfigForPhoneAccount(handle)
                .getBoolean(CarrierConfigManager.KEY_IGNORE_RTT_MODE_SETTING_BOOL, false);
        return isRttModeSettingOn && !shouldIgnoreRttModeSetting;
    }

    private PersistableBundle getCarrierConfigForPhoneAccount(PhoneAccountHandle handle) {
        int subscriptionId = mPhoneAccountRegistrar.getSubscriptionIdForPhoneAccount(handle);
        CarrierConfigManager carrierConfigManager =
                mContext.getSystemService(CarrierConfigManager.class);
        PersistableBundle result = carrierConfigManager.getConfigForSubId(subscriptionId);
        return result == null ? new PersistableBundle() : result;
    }

    void phoneAccountSelected(Call call, PhoneAccountHandle account, boolean setDefault) {
+4 −1
Original line number Diff line number Diff line
@@ -1400,10 +1400,13 @@ public class TelecomServiceImpl {
                return;
            }


            if (args.length > 0 && Analytics.ANALYTICS_DUMPSYS_ARG.equals(args[0])) {
                Analytics.dumpToEncodedProto(writer, args);
                Binder.withCleanCallingIdentity(() ->
                        Analytics.dumpToEncodedProto(mContext, writer, args));
                return;
            }

            boolean isTimeLineView = (args.length > 0 && TIME_LINE_ARG.equalsIgnoreCase(args[0]));

            final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
+1 −1
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ public class CallScreeningServiceController implements IncomingCallFilter.CallFi
        PersistableBundle configBundle = configManager.getConfig();
        if (configBundle != null) {
            componentName = ComponentName.unflattenFromString(configBundle.getString
                    (CarrierConfigManager.KEY_CARRIER_CALL_SCREENING_APP_STRING));
                    (CarrierConfigManager.KEY_CARRIER_CALL_SCREENING_APP_STRING, ""));
        }

        return componentName != null ? componentName.getPackageName() : null;
Loading