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

Commit 1c31a73a authored by Kihong Seong's avatar Kihong Seong
Browse files

Handle null identity address in BluetoothOppService

Change functions to use a Util method to accommodate the behavior
correction where identity address can be null

Bug: 317120534
Bug: 295907764
Test: m com.android.btservices
Change-Id: I5287a796d8ec7bd0f07882dd4dce51a3ebc4e18e
parent c4e4b18e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.bluetooth.BluetoothDevicePicker;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProtoEnums;
import android.bluetooth.BluetoothSocket;
import android.bluetooth.BluetoothUtils;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -62,6 +63,7 @@ import com.android.bluetooth.BluetoothObexTransport;
import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.IObexConnectionHandler;
import com.android.bluetooth.ObexServerSockets;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.content_profiles.ContentProfileErrorReportUtils;
@@ -1307,13 +1309,15 @@ public class BluetoothOppService extends ProfileService implements IObexConnecti

    @Override
    public boolean onConnect(BluetoothDevice device, BluetoothSocket socket) {

        Log.d(
                TAG,
                " onConnect BluetoothSocket :"
                        + socket
                        + " \n :device :"
                        + device.getIdentityAddress());
                        + BluetoothUtils.toAnonymizedAddress(
                                Flags.identityAddressNullIfUnknown()
                                        ? Utils.getBrEdrAddress(device)
                                        : device.getIdentityAddress()));
        if (!mAcceptNewConnections) {
            Log.d(TAG, " onConnect BluetoothSocket :" + socket + " rejected");
            return false;