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

Commit 1a01f525 authored by Kihong Seong's avatar Kihong Seong Committed by Gerrit Code Review
Browse files

Merge "Handle null identity address in BluetoothOppManager" into main

parents d61c8e07 9d1ee9af
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -186,6 +186,20 @@ public final class Utils {
        return String.format("XX:XX:XX:XX:%02X:%02X", address[4], address[5]);
    }

    /**
     * Returns the correct device address to be used for connections over BR/EDR transport.
     *
     * @param device the device for which to obtain the connection address
     * @return either identity address or device address in String format
     */
    public static String getBrEdrAddress(BluetoothDevice device) {
        String address = device.getIdentityAddress();
        if (address == null) {
            address = device.getAddress();
        }
        return address;
    }

    /**
     * Returns the correct device address to be used for connections over BR/EDR transport.
     *
+12 −2
Original line number Diff line number Diff line
@@ -51,7 +51,9 @@ import android.util.Pair;
import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.R;
import com.android.bluetooth.Utils;
import com.android.bluetooth.content_profiles.ContentProfileErrorReportUtils;
import com.android.bluetooth.flags.Flags;
import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
@@ -502,7 +504,11 @@ public class BluetoothOppManager {
                }

                values.put(BluetoothShare.MIMETYPE, contentType);
                values.put(BluetoothShare.DESTINATION, mRemoteDevice.getIdentityAddress());
                values.put(
                        BluetoothShare.DESTINATION,
                        Flags.identityAddressNullIfUnknown()
                                ? Utils.getBrEdrAddress(mRemoteDevice)
                                : mRemoteDevice.getIdentityAddress());
                values.put(BluetoothShare.TIMESTAMP, ts);
                if (mIsHandoverInitiated) {
                    values.put(BluetoothShare.USER_CONFIRMATION,
@@ -524,7 +530,11 @@ public class BluetoothOppManager {
            ContentValues values = new ContentValues();
            values.put(BluetoothShare.URI, mUri);
            values.put(BluetoothShare.MIMETYPE, mTypeOfSingleFile);
            values.put(BluetoothShare.DESTINATION, mRemoteDevice.getIdentityAddress());
            values.put(
                    BluetoothShare.DESTINATION,
                    Flags.identityAddressNullIfUnknown()
                            ? Utils.getBrEdrAddress(mRemoteDevice)
                            : mRemoteDevice.getIdentityAddress());
            if (mIsHandoverInitiated) {
                values.put(BluetoothShare.USER_CONFIRMATION,
                        BluetoothShare.USER_CONFIRMATION_HANDOVER_CONFIRMED);