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

Commit b965bbd5 authored by William Escande's avatar William Escande
Browse files

HidHost: Remove quiet mode dead code

mTarget is null and never set in the code. Exiting the quiet mode does
nothing.
Removing this whole code since the potential call to offToBleOn is very
scary (even if impossible to trigger, since when bluetooth is off, there
is no HidHost code that run)

Bug: 311772251
Test: None
Flag: Exempt dead code removal
Change-Id: I204cd8c639b9a21f44ca3b53382f0f1808e2ef51
parent 0209fb30
Loading
Loading
Loading
Loading
+1 −21
Original line number Diff line number Diff line
@@ -109,7 +109,6 @@ public class HidHostService extends ProfileService {
    private final HidHostNativeInterface mNativeInterface;

    private boolean mNativeAvailable;
    private BluetoothDevice mTargetDevice = null;

    private static final int MESSAGE_CONNECT = 1;
    private static final int MESSAGE_DISCONNECT = 2;
@@ -698,7 +697,6 @@ public class HidHostService extends ProfileService {
        if (Flags.allowSwitchingHidAndHogp() || connectionAllowed) {
            updateConnectionState(device, transport, reportedState);
        }
        updateQuietMode(device, reportedState);
    }

    private void handleMessageDisconnect(Message msg) {
@@ -781,23 +779,6 @@ public class HidHostService extends ProfileService {
        return true;
    }

    /**
     * Disables the quiet mode if target device gets connected
     *
     * @param device remote device
     * @param state connection state
     */
    private void updateQuietMode(BluetoothDevice device, int state) {
        if (state == BluetoothProfile.STATE_CONNECTED
                && mTargetDevice != null
                && mTargetDevice.equals(device)) {
            // Locally initiated connection, move out of quiet mode
            Log.i(TAG, "updateQuietMode: Move out of quiet mode. device=" + device);
            mTargetDevice = null;
            mAdapterService.enable(false);
        }
    }

    @VisibleForTesting
    static class BluetoothHidHostBinder extends IBluetoothHidHost.Stub
            implements IProfileServiceBinder {
@@ -1482,7 +1463,7 @@ public class HidHostService extends ProfileService {
    @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
    public boolean okToConnect(BluetoothDevice device) {
        // Check if this is an incoming connection in Quiet mode.
        if (mAdapterService.isQuietModeEnabled() && mTargetDevice == null) {
        if (mAdapterService.isQuietModeEnabled()) {
            Log.w(TAG, "okToConnect: return false because of quiet mode enabled. device=" + device);
            return false;
        }
@@ -1510,7 +1491,6 @@ public class HidHostService extends ProfileService {
    @Override
    public void dump(StringBuilder sb) {
        super.dump(sb);
        println(sb, "mTargetDevice: " + mTargetDevice);
        println(sb, "mInputDevices:");
        mInputDevices.forEach((k, v) -> sb.append(" " + k + " : " + v + "\n"));
    }