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

Commit fcbbdcf1 authored by Sal Savage's avatar Sal Savage
Browse files

Refactor PAN logging to be unguarded

With the recent addition of a process minimum default log level, the
Android Log framework will now enforce the set log level against the
various log invocations we make in code. We no longer need to guard log
invocations on our own.

Tag: #refactor
Flag: EXEMPT, logging only change
Bug: 315046089
Test: atest BluetoothInstrumentationTests
Change-Id: I6b832df3a757c18228c16a722b7b3c5155aae037
parent c97241ae
Loading
Loading
Loading
Loading
+17 −32
Original line number Original line Diff line number Diff line
@@ -63,8 +63,7 @@ import java.util.Objects;
 * the Bluetooth application.
 * the Bluetooth application.
 */
 */
public class PanService extends ProfileService {
public class PanService extends ProfileService {
    private static final String TAG = "PanService";
    private static final String TAG = PanService.class.getSimpleName();
    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);
    private static PanService sPanService;
    private static PanService sPanService;


    private static final int BLUETOOTH_MAX_PAN_CONNECTIONS = 5;
    private static final int BLUETOOTH_MAX_PAN_CONNECTIONS = 5;
@@ -138,9 +137,7 @@ public class PanService extends ProfileService {
    }
    }


    private static synchronized void setPanService(PanService instance) {
    private static synchronized void setPanService(PanService instance) {
        if (DBG) {
        Log.d(TAG, "setPanService(): set to: " + instance);
        Log.d(TAG, "setPanService(): set to: " + instance);
        }
        sPanService = instance;
        sPanService = instance;
    }
    }


@@ -265,14 +262,12 @@ public class PanService extends ProfileService {
                            final BluetoothDevice device =
                            final BluetoothDevice device =
                                    mAdapterService.getDeviceFromByte(cs.addr);
                                    mAdapterService.getDeviceFromByte(cs.addr);
                            // TBD get iface from the msg
                            // TBD get iface from the msg
                            if (DBG) {
                            Log.d(
                            Log.d(
                                    TAG,
                                    TAG,
                                    "MESSAGE_CONNECT_STATE_CHANGED: "
                                    "MESSAGE_CONNECT_STATE_CHANGED: "
                                            + device
                                            + device
                                            + " state: "
                                            + " state: "
                                            + cs.state);
                                            + cs.state);
                            }
                            // It could be null if the connection up is coming when the
                            // It could be null if the connection up is coming when the
                            // Bluetooth is turning off.
                            // Bluetooth is turning off.
                            if (device == null) {
                            if (device == null) {
@@ -486,9 +481,7 @@ public class PanService extends ProfileService {
    })
    })
    void setBluetoothTethering(IBluetoothPanCallback callback, int id, int callerUid,
    void setBluetoothTethering(IBluetoothPanCallback callback, int id, int callerUid,
            boolean value) {
            boolean value) {
        if (DBG) {
        Log.d(TAG, "setBluetoothTethering: " + value + ", mTetherOn: " + mTetherOn);
        Log.d(TAG, "setBluetoothTethering: " + value + ", mTetherOn: " + mTetherOn);
        }
        enforceCallingOrSelfPermission(
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        enforceCallingOrSelfPermission(
        enforceCallingOrSelfPermission(
@@ -550,9 +543,7 @@ public class PanService extends ProfileService {
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        enforceCallingOrSelfPermission(
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        if (DBG) {
        Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        }


        if (!mDatabaseManager.setProfileConnectionPolicy(device, BluetoothProfile.PAN,
        if (!mDatabaseManager.setProfileConnectionPolicy(device, BluetoothProfile.PAN,
                  connectionPolicy)) {
                  connectionPolicy)) {
@@ -625,10 +616,8 @@ public class PanService extends ProfileService {


    void onConnectStateChanged(byte[] address, int state, int error, int localRole,
    void onConnectStateChanged(byte[] address, int state, int error, int localRole,
            int remoteRole) {
            int remoteRole) {
        if (DBG) {
        Log.d(TAG, "onConnectStateChanged: " + state + ", local role:" + localRole
        Log.d(TAG, "onConnectStateChanged: " + state + ", local role:" + localRole
                + ", remoteRole: " + remoteRole);
                + ", remoteRole: " + remoteRole);
        }
        Message msg = mHandler.obtainMessage(MESSAGE_CONNECT_STATE_CHANGED);
        Message msg = mHandler.obtainMessage(MESSAGE_CONNECT_STATE_CHANGED);
        msg.obj = new ConnectState(address, state, error, localRole, remoteRole);
        msg.obj = new ConnectState(address, state, error, localRole, remoteRole);
        mHandler.sendMessage(msg);
        mHandler.sendMessage(msg);
@@ -636,10 +625,8 @@ public class PanService extends ProfileService {


    @VisibleForTesting
    @VisibleForTesting
    void onControlStateChanged(int localRole, int state, int error, String ifname) {
    void onControlStateChanged(int localRole, int state, int error, String ifname) {
        if (DBG) {
        Log.d(TAG, "onControlStateChanged: " + state + ", error: " + error + ", ifname: "
        Log.d(TAG, "onControlStateChanged: " + state + ", error: " + error + ", ifname: "
                + ifname);
                + ifname);
        }
        if (error == 0) {
        if (error == 0) {
            mPanIfName = ifname;
            mPanIfName = ifname;
        }
        }
@@ -648,11 +635,9 @@ public class PanService extends ProfileService {


    void handlePanDeviceStateChange(BluetoothDevice device, String iface, int state,
    void handlePanDeviceStateChange(BluetoothDevice device, String iface, int state,
            @LocalPanRole int localRole, @RemotePanRole int remoteRole) {
            @LocalPanRole int localRole, @RemotePanRole int remoteRole) {
        if (DBG) {
        Log.d(TAG, "handlePanDeviceStateChange: device: " + device + ", iface: " + iface
        Log.d(TAG, "handlePanDeviceStateChange: device: " + device + ", iface: " + iface
                + ", state: " + state + ", localRole:" + localRole + ", remoteRole:"
                + ", state: " + state + ", localRole:" + localRole + ", remoteRole:"
                + remoteRole);
                + remoteRole);
        }
        int prevState;
        int prevState;


        BluetoothPanDevice panDevice = mPanDevices.get(device);
        BluetoothPanDevice panDevice = mPanDevices.get(device);