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

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

Snap for 8362632 from b6619d89 to tm-release

Change-Id: I78d6f38264be8ea5a19e21eb79286eb1a83c866d
parents 8b64d0c9 b6619d89
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@
    <string name="non_primary_user" msgid="315564589279622098">"Alleen de eigenaar van het apparaat kan geblokkeerd nummers bekijken en beheren."</string>
    <string name="delete_icon_description" msgid="5335959254954774373">"Blokkering opheffen"</string>
    <string name="blocked_numbers_butter_bar_title" msgid="582982373755950791">"Blokkering tijdelijk uitgezet"</string>
    <string name="blocked_numbers_butter_bar_body" msgid="1261213114919301485">"Als je een noodnummer belt of er een sms naartoe stuurt, wordt de blokkering uitgeschakeld om te zorgen dat hulpdiensten contact met je kunnen opnemen."</string>
    <string name="blocked_numbers_butter_bar_body" msgid="1261213114919301485">"Als je een noodnummer belt of er een sms naartoe stuurt, wordt de blokkering uitgezet om te zorgen dat hulpdiensten contact met je kunnen opnemen."</string>
    <string name="blocked_numbers_butter_bar_button" msgid="2704456308072489793">"Nu opnieuw aanzetten"</string>
    <string name="blocked_numbers_number_blocked_message" msgid="4314736791180919167">"<xliff:g id="BLOCKED_NUMBER">%1$s</xliff:g> geblokkeerd"</string>
    <string name="blocked_numbers_number_unblocked_message" msgid="2933071624674945601">"Blokkering van <xliff:g id="UNBLOCKED_NUMBER">%1$s</xliff:g> opgeheven"</string>
+22 −28
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.os.Process.myUid;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.compat.CompatChanges;
import android.app.Notification;
@@ -90,17 +91,6 @@ public class InCallController extends CallsManagerListenerBase implements
        AppOpsManager.OnOpActiveChangedListener {
    public static final String NOTIFICATION_TAG = InCallController.class.getSimpleName();
    public static final int IN_CALL_SERVICE_NOTIFICATION_ID = 3;

    /**
     * Enable a crash notification if the default dialer app does not implement the
     * {@link InCallService} and the system Dialer takes over.
     *
     * @hide
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
    public static final long ENABLE_NOTIFICATION_FOR_DEFAULT_DIALER_CRASH = 218903401L; // bug id

    public class InCallServiceConnection {
        /**
         * Indicates that a call to {@link #connect(Call)} has succeeded and resulted in a
@@ -1622,27 +1612,31 @@ public class InCallController extends CallsManagerListenerBase implements
        mNonUIInCallServiceConnections.connect(call);
    }

    private InCallServiceInfo getDefaultDialerComponent() {
        String packageName = mDefaultDialerCache.getDefaultDialerApplication(
    private @Nullable InCallServiceInfo getDefaultDialerComponent() {
        String defaultPhoneAppName = mDefaultDialerCache.getDefaultDialerApplication(
                mCallsManager.getCurrentUserHandle().getIdentifier());
        String systemPackageName = mDefaultDialerCache.getSystemDialerApplication();
        Log.d(this, "Default Dialer package: " + packageName);

        InCallServiceInfo defaultDialerComponent =
                (systemPackageName != null && systemPackageName.equals(packageName))
                        ? getInCallServiceComponent(packageName, IN_CALL_SERVICE_TYPE_SYSTEM_UI,
                        true /* ignoreDisabled */)
                        : getInCallServiceComponent(packageName,
        String systemPhoneAppName = mDefaultDialerCache.getSystemDialerApplication();

        Log.d(this, "getDefaultDialerComponent: defaultPhoneAppName=[%s]", defaultPhoneAppName);
        Log.d(this, "getDefaultDialerComponent: systemPhoneAppName=[%s]", systemPhoneAppName);

        // Get the defaultPhoneApp InCallService component...
        InCallServiceInfo defaultPhoneAppComponent =
                (systemPhoneAppName != null && systemPhoneAppName.equals(defaultPhoneAppName)) ?
                        /* The defaultPhoneApp is also the systemPhoneApp. Get systemPhoneApp info*/
                        getInCallServiceComponent(defaultPhoneAppName,
                                IN_CALL_SERVICE_TYPE_SYSTEM_UI, true /* ignoreDisabled */)
                        /* The defaultPhoneApp is NOT the systemPhoneApp. Get defaultPhoneApp info*/
                        : getInCallServiceComponent(defaultPhoneAppName,
                                IN_CALL_SERVICE_TYPE_DEFAULT_DIALER_UI, true /* ignoreDisabled */);

        if (packageName != null && defaultDialerComponent == null &&
                CompatChanges.isChangeEnabled(ENABLE_NOTIFICATION_FOR_DEFAULT_DIALER_CRASH,
                        Binder.getCallingUid())) {
            // The in call service of default phone app is disabled, send notification.
            sendCrashedInCallServiceNotification(packageName);
        }
        Log.d(this, "getDefaultDialerComponent: defaultPhoneAppComponent=[%s]",
                defaultPhoneAppComponent);

        // defaultPhoneAppComponent is null in the case when the defaultPhoneApp does not implement
        // the InCallService && is the package is different from the systemPhoneApp

        return defaultDialerComponent;
        return defaultPhoneAppComponent;
    }

    private InCallServiceInfo getCurrentCarModeComponent() {
+40 −7
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.os.SystemClock;
import android.telecom.Logging.EventManager;
import android.telecom.Logging.EventManager.TimedEventPair;

import com.android.internal.annotations.VisibleForTesting;

import java.util.HashMap;
import java.util.Map;

@@ -34,6 +36,9 @@ public class LogUtils {
    private static final String LOGUTILS_TAG = "LogUtils";

    public static final boolean SYSTRACE_DEBUG = false; /* STOP SHIP if true */
    private static boolean sInitializedLoggerListeners = false; // used to gate re-init of listeners
    private static int sInitializedCounter = 0; /* For testing purposes only */
    private static final Object sLock = new Object(); // Coarse lock for all of LogUtils

    public static class EventTimer {
        private long mLastElapsedMillis;
@@ -263,6 +268,14 @@ public class LogUtils {
    }

    public static void initLogging(Context context) {
        android.telecom.Log.d(LOGUTILS_TAG, "initLogging: attempting to acquire LogUtils sLock");
        synchronized (sLock) {
            android.telecom.Log.d(LOGUTILS_TAG, "initLogging: grabbed LogUtils sLock");
            if (!sInitializedLoggerListeners) {
                android.telecom.Log.d(LOGUTILS_TAG,
                        "initLogging: called for first time. Registering the EventListener &"
                                + " SessionListener.");

                android.telecom.Log.setTag(TAG);
                android.telecom.Log.setSessionContext(context);
                for (EventManager.TimedEventPair p : Events.Timings.sTimedEvents) {
@@ -271,5 +284,25 @@ public class LogUtils {
                android.telecom.Log.registerEventListener(LogUtils::eventRecordAdded);
                // Store analytics about recently completed Sessions.
                android.telecom.Log.registerSessionListener(Analytics::addSessionTiming);

                // Ensure LogUtils#initLogging(Context) is called once throughout the entire
                // lifecycle of not only TelecomSystem, but the Testing Framework.
                sInitializedLoggerListeners = true;
                sInitializedCounter++; /* For testing purposes only */
            } else {
                android.telecom.Log.d(LOGUTILS_TAG, "initLogging: called again. Doing nothing.");
            }
        }
    }

    /**
     * Needed in order to test if the registerEventListener & registerSessionListener are ever
     * re-initialized in the entire process of the Testing Framework or TelecomSystem.
     *
     * @return the number of times initLogging(Context) listeners have been initialized
     */
    @VisibleForTesting
    public static int getInitializedCounter() {
        return sInitializedCounter;
    }
}
+37 −37
Original line number Diff line number Diff line
@@ -56,9 +56,9 @@ public class BluetoothRouteManager extends StateMachine {
    private static final SparseArray<String> MESSAGE_CODE_TO_NAME = new SparseArray<String>() {{
         put(NEW_DEVICE_CONNECTED, "NEW_DEVICE_CONNECTED");
         put(LOST_DEVICE, "LOST_DEVICE");
         put(CONNECT_HFP, "CONNECT_HFP");
         put(DISCONNECT_HFP, "DISCONNECT_HFP");
         put(RETRY_HFP_CONNECTION, "RETRY_HFP_CONNECTION");
         put(CONNECT_BT, "CONNECT_BT");
         put(DISCONNECT_BT, "DISCONNECT_BT");
         put(RETRY_BT_CONNECTION, "RETRY_BT_CONNECTION");
         put(BT_AUDIO_IS_ON, "BT_AUDIO_IS_ON");
         put(BT_AUDIO_LOST, "BT_AUDIO_LOST");
         put(CONNECTION_TIMEOUT, "CONNECTION_TIMEOUT");
@@ -98,11 +98,11 @@ public class BluetoothRouteManager extends StateMachine {
    public static final int LOST_DEVICE = 2;

    // arg2 (optional): the address of the specific device to connect to.
    public static final int CONNECT_HFP = 100;
    public static final int CONNECT_BT = 100;
    // No args.
    public static final int DISCONNECT_HFP = 101;
    public static final int DISCONNECT_BT = 101;
    // arg2: the address of the device to connect to.
    public static final int RETRY_HFP_CONNECTION = 102;
    public static final int RETRY_BT_CONNECTION = 102;

    // arg2: the address of the device that is on
    public static final int BT_AUDIO_IS_ON = 200;
@@ -159,29 +159,29 @@ public class BluetoothRouteManager extends StateMachine {
                    case LOST_DEVICE:
                        removeDevice((String) args.arg2);
                        break;
                    case CONNECT_HFP:
                    case CONNECT_BT:
                        String actualAddress = connectBtAudio((String) args.arg2,
                            false /* switchingBtDevices*/);

                        if (actualAddress != null) {
                            transitionTo(getConnectingStateForAddress(actualAddress,
                                    "AudioOff/CONNECT_HFP"));
                                    "AudioOff/CONNECT_BT"));
                        } else {
                            Log.w(LOG_TAG, "Tried to connect to %s but failed to connect to" +
                                    " any HFP device.", (String) args.arg2);
                                    " any BT device.", (String) args.arg2);
                        }
                        break;
                    case DISCONNECT_HFP:
                    case DISCONNECT_BT:
                        // Ignore.
                        break;
                    case RETRY_HFP_CONNECTION:
                        Log.i(LOG_TAG, "Retrying HFP connection to %s", (String) args.arg2);
                    case RETRY_BT_CONNECTION:
                        Log.i(LOG_TAG, "Retrying BT connection to %s", (String) args.arg2);
                        String retryAddress = connectBtAudio((String) args.arg2, args.argi1,
                            false /* switchingBtDevices*/);

                        if (retryAddress != null) {
                            transitionTo(getConnectingStateForAddress(retryAddress,
                                    "AudioOff/RETRY_HFP_CONNECTION"));
                                    "AudioOff/RETRY_BT_CONNECTION"));
                        } else {
                            Log.i(LOG_TAG, "Retry failed.");
                        }
@@ -191,12 +191,12 @@ public class BluetoothRouteManager extends StateMachine {
                        break;
                    case BT_AUDIO_IS_ON:
                        String address = (String) args.arg2;
                        Log.w(LOG_TAG, "HFP audio unexpectedly turned on from device %s", address);
                        Log.w(LOG_TAG, "BT audio unexpectedly turned on from device %s", address);
                        transitionTo(getConnectedStateForAddress(address,
                                "AudioOff/BT_AUDIO_IS_ON"));
                        break;
                    case BT_AUDIO_LOST:
                        Log.i(LOG_TAG, "Received HFP off for device %s while HFP off.",
                        Log.i(LOG_TAG, "Received BT off for device %s while BT off.",
                                (String) args.arg2);
                        mListener.onUnexpectedBluetoothStateChange();
                        break;
@@ -262,7 +262,7 @@ public class BluetoothRouteManager extends StateMachine {
                            transitionToActualState();
                        }
                        break;
                    case CONNECT_HFP:
                    case CONNECT_BT:
                        if (!switchingBtDevices) {
                            // Ignore repeated connection attempts to the same device
                            break;
@@ -272,16 +272,16 @@ public class BluetoothRouteManager extends StateMachine {
                            true /* switchingBtDevices*/);
                        if (actualAddress != null) {
                            transitionTo(getConnectingStateForAddress(actualAddress,
                                    "AudioConnecting/CONNECT_HFP"));
                                    "AudioConnecting/CONNECT_BT"));
                        } else {
                            Log.w(LOG_TAG, "Tried to connect to %s but failed" +
                                    " to connect to any HFP device.", (String) args.arg2);
                                    " to connect to any BT device.", (String) args.arg2);
                        }
                        break;
                    case DISCONNECT_HFP:
                    case DISCONNECT_BT:
                        mDeviceManager.disconnectAudio();
                        break;
                    case RETRY_HFP_CONNECTION:
                    case RETRY_BT_CONNECTION:
                        if (!switchingBtDevices) {
                            Log.d(LOG_TAG, "Retry message came through while connecting.");
                            break;
@@ -291,7 +291,7 @@ public class BluetoothRouteManager extends StateMachine {
                            true /* switchingBtDevices*/);
                        if (retryAddress != null) {
                            transitionTo(getConnectingStateForAddress(retryAddress,
                                    "AudioConnecting/RETRY_HFP_CONNECTION"));
                                    "AudioConnecting/RETRY_BT_CONNECTION"));
                        } else {
                            Log.i(LOG_TAG, "Retry failed.");
                        }
@@ -318,7 +318,7 @@ public class BluetoothRouteManager extends StateMachine {
                                    mDeviceAddress);
                            transitionToActualState();
                        } else {
                            Log.w(LOG_TAG, "Got HFP lost message for device %s while" +
                            Log.w(LOG_TAG, "Got BT lost message for device %s while" +
                                    " connecting to %s.", address, mDeviceAddress);
                            mListener.onUnexpectedBluetoothStateChange();
                        }
@@ -351,7 +351,7 @@ public class BluetoothRouteManager extends StateMachine {
        public void enter() {
            // Remove any of the retries that are still in the queue once any device becomes
            // connected.
            removeMessages(RETRY_HFP_CONNECTION);
            removeMessages(RETRY_BT_CONNECTION);
            // Remove and add to ensure that the device is at the top.
            mMostRecentlyUsedDevices.remove(mDeviceAddress);
            mMostRecentlyUsedDevices.add(mDeviceAddress);
@@ -379,7 +379,7 @@ public class BluetoothRouteManager extends StateMachine {
                            transitionToActualState();
                        }
                        break;
                    case CONNECT_HFP:
                    case CONNECT_BT:
                        if (!switchingBtDevices) {
                            // Ignore connection to already connected device.
                            break;
@@ -389,16 +389,16 @@ public class BluetoothRouteManager extends StateMachine {
                            true /* switchingBtDevices*/);
                        if (actualAddress != null) {
                            transitionTo(getConnectingStateForAddress(address,
                                    "AudioConnected/CONNECT_HFP"));
                                    "AudioConnected/CONNECT_BT"));
                        } else {
                            Log.w(LOG_TAG, "Tried to connect to %s but failed" +
                                    " to connect to any HFP device.", (String) args.arg2);
                                    " to connect to any BT device.", (String) args.arg2);
                        }
                        break;
                    case DISCONNECT_HFP:
                    case DISCONNECT_BT:
                        mDeviceManager.disconnectAudio();
                        break;
                    case RETRY_HFP_CONNECTION:
                    case RETRY_BT_CONNECTION:
                        if (!switchingBtDevices) {
                            Log.d(LOG_TAG, "Retry message came through while connected.");
                            break;
@@ -408,7 +408,7 @@ public class BluetoothRouteManager extends StateMachine {
                            true /* switchingBtDevices*/);
                        if (retryAddress != null) {
                            transitionTo(getConnectingStateForAddress(retryAddress,
                                    "AudioConnected/RETRY_HFP_CONNECTION"));
                                    "AudioConnected/RETRY_BT_CONNECTION"));
                        } else {
                            Log.i(LOG_TAG, "Retry failed.");
                        }
@@ -429,10 +429,10 @@ public class BluetoothRouteManager extends StateMachine {
                        break;
                    case BT_AUDIO_LOST:
                        if (Objects.equals(mDeviceAddress, address) || address == null) {
                            Log.i(LOG_TAG, "HFP connection with device %s lost.", mDeviceAddress);
                            Log.i(LOG_TAG, "BT connection with device %s lost.", mDeviceAddress);
                            transitionToActualState();
                        } else {
                            Log.w(LOG_TAG, "Got HFP lost message for device %s while" +
                            Log.w(LOG_TAG, "Got BT lost message for device %s while" +
                                    " connected to %s.", address, mDeviceAddress);
                            mListener.onUnexpectedBluetoothStateChange();
                        }
@@ -461,7 +461,7 @@ public class BluetoothRouteManager extends StateMachine {

    private BluetoothStateListener mListener;
    private BluetoothDeviceManager mDeviceManager;
    // Tracks the active devices in the BT stack (HFP or hearing aid).
    // Tracks the active devices in the BT stack (HFP or hearing aid or le audio).
    private BluetoothDevice mHfpActiveDeviceCache = null;
    private BluetoothDevice mHearingAidActiveDeviceCache = null;
    private BluetoothDevice mLeAudioActiveDeviceCache = null;
@@ -505,7 +505,7 @@ public class BluetoothRouteManager extends StateMachine {
    }

    /**
     * Returns whether there is a HFP device available to route audio to.
     * Returns whether there is a BT device available to route audio to.
     * @return true if there is a device, false otherwise.
     */
    public boolean isBluetoothAvailable() {
@@ -550,16 +550,16 @@ public class BluetoothRouteManager extends StateMachine {
        SomeArgs args = SomeArgs.obtain();
        args.arg1 = Log.createSubsession();
        args.arg2 = address;
        sendMessage(CONNECT_HFP, args);
        sendMessage(CONNECT_BT, args);
    }

    /**
     * Disconnects Bluetooth HFP audio.
     * Disconnects Bluetooth audio.
     */
    public void disconnectBluetoothAudio() {
        SomeArgs args = SomeArgs.obtain();
        args.arg1 = Log.createSubsession();
        sendMessage(DISCONNECT_HFP, args);
        sendMessage(DISCONNECT_BT, args);
    }

    public void disconnectAudio() {
@@ -708,7 +708,7 @@ public class BluetoothRouteManager extends StateMachine {
                args.arg1 = Log.createSubsession();
                args.arg2 = actualAddress;
                args.argi1 = retryCount + 1;
                sendMessageDelayed(RETRY_HFP_CONNECTION, args,
                sendMessageDelayed(RETRY_BT_CONNECTION, args,
                        mTimeoutsAdapter.getRetryBluetoothConnectAudioBackoffMillis(
                                mContext.getContentResolver()));
            }
+4 −4
Original line number Diff line number Diff line
@@ -85,14 +85,14 @@ public class BluetoothRouteManagerTest extends TelecomTestCase {

    @SmallTest
    @Test
    public void testConnectHfpRetryWhileNotConnected() {
    public void testConnectBtRetryWhileNotConnected() {
        BluetoothRouteManager sm = setupStateMachine(
                BluetoothRouteManager.AUDIO_OFF_STATE_NAME, null);
        setupConnectedDevices(new BluetoothDevice[]{DEVICE1}, null, null, null, null, null);
        when(mTimeoutsAdapter.getRetryBluetoothConnectAudioBackoffMillis(
                nullable(ContentResolver.class))).thenReturn(0L);
        when(mBluetoothHeadset.connectAudio()).thenReturn(BluetoothStatusCodes.ERROR_UNKNOWN);
        executeRoutingAction(sm, BluetoothRouteManager.CONNECT_HFP, DEVICE1.getAddress());
        executeRoutingAction(sm, BluetoothRouteManager.CONNECT_BT, DEVICE1.getAddress());
        // Wait 3 times: for the first connection attempt, the retry attempt,
        // the second retry, and once more to make sure there are only three attempts.
        waitForHandlerAction(sm.getHandler(), TEST_TIMEOUT);
@@ -146,7 +146,7 @@ public class BluetoothRouteManagerTest extends TelecomTestCase {

    @SmallTest
    @Test
    public void testConnectHfpRetryWhileConnectedToAnotherDevice() {
    public void testConnectBtRetryWhileConnectedToAnotherDevice() {
        BluetoothRouteManager sm = setupStateMachine(
                BluetoothRouteManager.AUDIO_CONNECTED_STATE_NAME_PREFIX, DEVICE1);
        setupConnectedDevices(new BluetoothDevice[]{DEVICE1, DEVICE2}, null, null, null, null,
@@ -154,7 +154,7 @@ public class BluetoothRouteManagerTest extends TelecomTestCase {
        when(mTimeoutsAdapter.getRetryBluetoothConnectAudioBackoffMillis(
                nullable(ContentResolver.class))).thenReturn(0L);
        when(mBluetoothHeadset.connectAudio()).thenReturn(BluetoothStatusCodes.ERROR_UNKNOWN);
        executeRoutingAction(sm, BluetoothRouteManager.CONNECT_HFP, DEVICE2.getAddress());
        executeRoutingAction(sm, BluetoothRouteManager.CONNECT_BT, DEVICE2.getAddress());
        // Wait 3 times: the first connection attempt is accounted for in executeRoutingAction,
        // so wait twice for the retry attempt, again to make sure there are only three attempts,
        // and once more for good luck.
Loading