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

Commit b65d018f authored by Angela Wang's avatar Angela Wang
Browse files

Rename the misleading variable name in setEnabled()

The meaning of the variable "isEnabled" and the logic part is very misleading in setEnabled() function, which implemented by  many profile classes in settingslib.

The return value of setConnectionPolicy() called in setEnabled() is true if connectionPolicy is set, false on error. The variable's name maybe better called as "isSuccessful" instead of "isEnabled" for correct meaning of this value.

Bug: 254188027
Test: build pass
Change-Id: If1026495e70311096c483177b6d00ab714c87227
parent 231ac033
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -198,19 +198,19 @@ public class A2dpProfile implements LocalBluetoothProfile {

    @Override
    public boolean setEnabled(BluetoothDevice device, boolean enabled) {
        boolean isEnabled = false;
        boolean isSuccessful = false;
        if (mService == null) {
            return false;
        }
        if (enabled) {
            if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
                isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
                isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
            }
        } else {
            isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
            isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
        }

        return isEnabled;
        return isSuccessful;
    }
    boolean isA2dpPlaying() {
        if (mService == null) return false;
+4 −4
Original line number Diff line number Diff line
@@ -140,19 +140,19 @@ final class A2dpSinkProfile implements LocalBluetoothProfile {

    @Override
    public boolean setEnabled(BluetoothDevice device, boolean enabled) {
        boolean isEnabled = false;
        boolean isSuccessful = false;
        if (mService == null) {
            return false;
        }
        if (enabled) {
            if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
                isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
                isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
            }
        } else {
            isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
            isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
        }

        return isEnabled;
        return isSuccessful;
    }

    boolean isAudioPlaying() {
+4 −4
Original line number Diff line number Diff line
@@ -178,19 +178,19 @@ public class CsipSetCoordinatorProfile implements LocalBluetoothProfile {

    @Override
    public boolean setEnabled(BluetoothDevice device, boolean enabled) {
        boolean isEnabled = false;
        boolean isSuccessful = false;
        if (mService == null || device == null) {
            return false;
        }
        if (enabled) {
            if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
                isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
                isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
            }
        } else {
            isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
            isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
        }

        return isEnabled;
        return isSuccessful;
    }

    @Override
+4 −4
Original line number Diff line number Diff line
@@ -258,19 +258,19 @@ public class HapClientProfile implements LocalBluetoothProfile {

    @Override
    public boolean setEnabled(BluetoothDevice device, boolean enabled) {
        boolean isEnabled = false;
        boolean isSuccessful = false;
        if (mService == null || device == null) {
            return false;
        }
        if (enabled) {
            if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
                isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
                isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
            }
        } else {
            isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
            isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
        }

        return isEnabled;
        return isSuccessful;
    }

    @Override
+4 −4
Original line number Diff line number Diff line
@@ -165,19 +165,19 @@ public class HeadsetProfile implements LocalBluetoothProfile {

    @Override
    public boolean setEnabled(BluetoothDevice device, boolean enabled) {
        boolean isEnabled = false;
        boolean isSuccessful = false;
        if (mService == null) {
            return false;
        }
        if (enabled) {
            if (mService.getConnectionPolicy(device) < CONNECTION_POLICY_ALLOWED) {
                isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
                isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_ALLOWED);
            }
        } else {
            isEnabled = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
            isSuccessful = mService.setConnectionPolicy(device, CONNECTION_POLICY_FORBIDDEN);
        }

        return isEnabled;
        return isSuccessful;
    }

    public List<BluetoothDevice> getConnectedDevices() {
Loading