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

Commit 9d9075c8 authored by William Escande's avatar William Escande
Browse files

InCallService: Telephony and Telecom cannot be null

Acknowledge that the BluetoothInCallService cannot be created if there
is no TelephonyManager or TelecomManager

+ cleanup dead code related to variable not being nullable anymore

Bug: 330247213
Test: atest BluetoothInstrumentationTests:BluetoothInCallServiceTest
Flag: Exempt refactor
Change-Id: Ic576c05ff8cbb1dacce56b6ed24e710fd0e9c4ef
parent 96c8d709
Loading
Loading
Loading
Loading
+4 −16
Original line number Diff line number Diff line
@@ -514,11 +514,7 @@ public class BluetoothInCallService extends InCallService {
                }
            }
            if (TextUtils.isEmpty(address)) {
                if (mTelephonyManager == null) {
                    address = null;
                } else {
                address = mTelephonyManager.getLine1Number();
                }
                if (address == null) address = "";
            }
            return address;
@@ -730,8 +726,8 @@ public class BluetoothInCallService extends InCallService {
        Log.d(TAG, "onCreate");
        super.onCreate();
        mAdapter = requireNonNull(getSystemService(BluetoothManager.class)).getAdapter();
        mTelephonyManager = getSystemService(TelephonyManager.class);
        mTelecomManager = getSystemService(TelecomManager.class);
        mTelephonyManager = requireNonNull(getSystemService(TelephonyManager.class));
        mTelecomManager = requireNonNull(getSystemService(TelecomManager.class));
        mAdapter.getProfileProxy(this, mProfileListener, BluetoothProfile.HEADSET);
        mAdapter.getProfileProxy(this, mProfileListener, BluetoothProfile.LE_CALL_CONTROL);
        mBluetoothAdapterReceiver = new BluetoothAdapterReceiver();
@@ -828,10 +824,6 @@ public class BluetoothInCallService extends InCallService {
                        Log.w(TAG, "call id: " + bluetoothCall.getId() + " handle is null");
                        continue;
                    }
                    if (mTelephonyManager == null) {
                        Log.w(TAG, "mTelephonyManager is null");
                        continue;
                    }
                    boolean isSame =
                            PhoneNumberUtils.areSamePhoneNumber(
                                    bluetoothCall.getHandle().toString(),
@@ -1533,10 +1525,6 @@ public class BluetoothInCallService extends InCallService {

            if (account == null) {
                // Second, Try to get the label for the default Phone Account.
                if (mTelecomManager == null) {
                    Log.w(TAG, "mTelecomManager is null");
                    return null;
                }
                List<PhoneAccountHandle> handles =
                        mTelecomManager.getPhoneAccountsSupportingScheme(PhoneAccount.SCHEME_TEL);
                while (handles.iterator().hasNext()) {
@@ -1569,7 +1557,7 @@ public class BluetoothInCallService extends InCallService {
    public void setBluetoothLeCallControl(BluetoothLeCallControlProxy bluetoothTbs) {
        mBluetoothLeCallControl = bluetoothTbs;

        if ((mBluetoothLeCallControl) != null && (mTelecomManager != null)) {
        if ((mBluetoothLeCallControl) != null) {
            mBluetoothLeCallControl.registerBearer(
                    TAG,
                    new ArrayList<String>(Arrays.asList("tel")),