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

Commit 880ce2aa authored by Jack He's avatar Jack He
Browse files

Add info log for important APIs in Bluetooth stack

Bug: 339532590
Test: mm -j85
Flag: Exempt, logging only
Change-Id: I0556a8e8248bf8d2069727832b2c85cefe07a4ed
parent bee80915
Loading
Loading
Loading
Loading
+52 −1
Original line number Diff line number Diff line
@@ -2454,6 +2454,7 @@ public class AdapterService extends Service {
                return false;
            }

            Log.i(TAG, "startDiscovery: from " + Utils.getUidPidString());
            return service.startDiscovery(attributionSource);
        }

@@ -2467,7 +2468,7 @@ public class AdapterService extends Service {
                return false;
            }

            Log.d(TAG, "cancelDiscovery");
            Log.i(TAG, "cancelDiscovery: from " + Utils.getUidPidString());
            return service.mNativeInterface.cancelDiscovery();
        }

@@ -2587,6 +2588,14 @@ public class AdapterService extends Service {
            // BluetoothDevice#createBond requires BLUETOOTH_ADMIN only.
            service.enforceBluetoothPrivilegedPermissionIfNeeded(remoteP192Data, remoteP256Data);

            Log.i(
                    TAG,
                    "createBond: device="
                            + device
                            + ", transport="
                            + transport
                            + ", from "
                            + Utils.getUidPidString());
            return service.createBond(
                    device,
                    transport,
@@ -2608,6 +2617,8 @@ public class AdapterService extends Service {

            enforceBluetoothPrivilegedPermission(service);

            Log.i(TAG, "cancelBondProcess: device=" + device + ", from " + Utils.getUidPidString());

            DeviceProperties deviceProp = service.mRemoteDevices.getDeviceProperties(device);
            if (deviceProp != null) {
                deviceProp.setBondingInitiatedLocally(false);
@@ -2626,6 +2637,8 @@ public class AdapterService extends Service {
                return false;
            }

            Log.i(TAG, "removeBond: device=" + device + ", from " + Utils.getUidPidString());

            DeviceProperties deviceProp = service.mRemoteDevices.getDeviceProperties(device);
            if (deviceProp == null || deviceProp.getBondState() != BluetoothDevice.BOND_BONDED) {
                Log.w(
@@ -2763,6 +2776,12 @@ public class AdapterService extends Service {
                    || !Utils.checkConnectPermissionForDataDelivery(service, source, TAG)) {
                return false;
            }
            Log.i(
                    TAG,
                    "removeActiveDevice: profiles="
                            + profiles
                            + ", from "
                            + Utils.getUidPidString());
            return service.setActiveDevice(null, profiles);
        }

@@ -2778,6 +2797,15 @@ public class AdapterService extends Service {

            enforceBluetoothPrivilegedPermission(service);

            Log.i(
                    TAG,
                    "setActiveDevice: device="
                            + device
                            + ", profiles="
                            + profiles
                            + ", from "
                            + Utils.getUidPidString());

            return service.setActiveDevice(device, profiles);
        }

@@ -2817,6 +2845,13 @@ public class AdapterService extends Service {

            enforceBluetoothPrivilegedPermission(service);

            Log.i(
                    TAG,
                    "connectAllEnabledProfiles: device="
                            + device
                            + ", from "
                            + Utils.getUidPidString());

            try {
                return service.connectAllEnabledProfiles(device);
            } catch (Exception e) {
@@ -2848,6 +2883,13 @@ public class AdapterService extends Service {

            enforceBluetoothPrivilegedPermission(service);

            Log.i(
                    TAG,
                    "disconnectAllEnabledProfiles: device="
                            + device
                            + ", from "
                            + Utils.getUidPidString());

            try {
                return service.disconnectAllEnabledProfiles(device);
            } catch (Exception e) {
@@ -2978,6 +3020,15 @@ public class AdapterService extends Service {
                enforceBluetoothPrivilegedPermission(service);
            }

            Log.i(
                    TAG,
                    "fetchRemoteUuids: device="
                            + device
                            + ", transport="
                            + transport
                            + ", from "
                            + Utils.getUidPidString());

            service.mRemoteDevices.fetchUuids(device, transport);
            MetricsLogger.getInstance().cacheCount(BluetoothProtoEnums.SDP_FETCH_UUID_REQUEST, 1);
            return true;
+28 −1
Original line number Diff line number Diff line
@@ -23,12 +23,13 @@ import android.content.AttributionSource;
import android.os.Binder;
import android.os.ParcelFileDescriptor;
import android.os.ParcelUuid;
import android.util.Log;

import com.android.bluetooth.Utils;
import com.android.bluetooth.flags.Flags;

class BluetoothSocketManagerBinder extends IBluetoothSocketManager.Stub {
    private static final String TAG = "BluetoothSocketManagerBinder";
    private static final String TAG = "BtSocketManagerBinder";

    private static final int INVALID_FD = -1;

@@ -59,6 +60,19 @@ class BluetoothSocketManagerBinder extends IBluetoothSocketManager.Stub {
                        ? Utils.getBrEdrAddress(device)
                        : mService.getIdentityAddress(device.getAddress());

        Log.i(
                TAG,
                "connectSocket: device="
                        + device
                        + ", type="
                        + type
                        + ", uuid="
                        + uuid
                        + ", port="
                        + port
                        + ", from "
                        + Utils.getUidPidString());

        return marshalFd(
                mService.getNative()
                        .connectSocket(
@@ -83,6 +97,19 @@ class BluetoothSocketManagerBinder extends IBluetoothSocketManager.Stub {
            return null;
        }

        Log.i(
                TAG,
                "createSocketChannel: type="
                        + type
                        + ", serviceName="
                        + serviceName
                        + ", uuid="
                        + uuid
                        + ", port="
                        + port
                        + ", from "
                        + Utils.getUidPidString());

        return marshalFd(
                mService.getNative()
                        .createSocketChannel(
+1 −1
Original line number Diff line number Diff line
@@ -1257,7 +1257,7 @@ public class RemoteDevices {
                            + Utils.getRedactedAddressStringFromByte(address));
            return;
        }
        Log.d(TAG, "keyMissingCallback device: " + bluetoothDevice);
        Log.i(TAG, "keyMissingCallback device: " + bluetoothDevice);

        if (bluetoothDevice.getBondState() == BluetoothDevice.BOND_BONDED) {
            if (!Flags.keyMissingBroadcast()) {
+2 −2
Original line number Diff line number Diff line
@@ -1910,10 +1910,10 @@ public final class BluetoothDevice implements Parcelable, Attributable {
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
    private boolean createBondInternal(
            int transport, @Nullable OobData remoteP192Data, @Nullable OobData remoteP256Data) {
        if (DBG) log("createBondOutOfBand()");
        if (DBG) log("createBondInternal()");
        final IBluetooth service = getService();
        if (service == null || !isBluetoothEnabled()) {
            Log.w(TAG, "BT not enabled, createBondOutOfBand failed");
            Log.w(TAG, "BT not enabled, createBondInternal failed");
            if (DBG) log(Log.getStackTraceString(new Throwable()));
        } else if (NULL_MAC_ADDRESS.equals(mAddress)) {
            Log.e(TAG, "Unable to create bond, invalid address " + mAddress);