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

Commit 5963e818 authored by Sal Savage's avatar Sal Savage Committed by Automerger Merge Worker
Browse files

Merge changes I4ca60b59,I2cdc3b01,I7c007f60,I816d4696,I6cbc58ac into main am: 26253d1c

parents bf87268b 26253d1c
Loading
Loading
Loading
Loading
+10 −31
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ import java.util.Objects;
 */
public class BatteryService extends ProfileService {
    private static final String TAG = "BatteryService";
    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);

    // Timeout for state machine thread join, to prevent potential ANR.
    private static final int SM_THREAD_JOIN_TIMEOUT_MS = 1_000;
@@ -81,9 +80,7 @@ public class BatteryService extends ProfileService {

    @Override
    public void start() {
        if (DBG) {
        Log.d(TAG, "start()");
        }
        if (sBatteryService != null) {
            throw new IllegalStateException("start() called twice");
        }
@@ -103,9 +100,7 @@ public class BatteryService extends ProfileService {

    @Override
    public void stop() {
        if (DBG) {
        Log.d(TAG, "stop()");
        }
        if (sBatteryService == null) {
            Log.w(TAG, "stop() called before start()");
            return;
@@ -144,10 +139,8 @@ public class BatteryService extends ProfileService {

    @Override
    public void cleanup() {
        if (DBG) {
        Log.d(TAG, "cleanup()");
    }
    }

    /**
     * Gets the BatteryService instance
@@ -170,9 +163,7 @@ public class BatteryService extends ProfileService {
     */
    @VisibleForTesting
    public static synchronized void setBatteryService(BatteryService instance) {
        if (DBG) {
        Log.d(TAG, "setBatteryService(): set to: " + instance);
        }
        sBatteryService = instance;
    }

@@ -183,9 +174,7 @@ public class BatteryService extends ProfileService {
    public boolean connect(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED,
                "Need BLUETOOTH_PRIVILEGED permission");
        if (DBG) {
        Log.d(TAG, "connect(): " + device);
        }
        if (device == null) {
            Log.w(TAG, "Ignore connecting to null device");
            return false;
@@ -235,9 +224,7 @@ public class BatteryService extends ProfileService {
    public boolean disconnect(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED,
                "Need BLUETOOTH_PRIVILEGED permission");
        if (DBG) {
        Log.d(TAG, "disconnect(): " + device);
        }
        if (device == null) {
            Log.w(TAG, "Ignore disconnecting to null device");
            return false;
@@ -314,9 +301,7 @@ public class BatteryService extends ProfileService {
        if (toState == BluetoothProfile.STATE_DISCONNECTED) {
            int bondState = mAdapterService.getBondState(device);
            if (bondState == BluetoothDevice.BOND_NONE) {
                if (DBG) {
                Log.d(TAG, device + " is unbonded. Remove state machine");
                }
                removeStateMachine(device);
            }
        }
@@ -403,9 +388,7 @@ public class BatteryService extends ProfileService {
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED,
                "Need BLUETOOTH_PRIVILEGED permission");
        if (DBG) {
        Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        }
        mDatabaseManager.setProfileConnectionPolicy(device, BluetoothProfile.BATTERY,
                        connectionPolicy);
        if (connectionPolicy == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
@@ -449,9 +432,7 @@ public class BatteryService extends ProfileService {
                        + MAX_BATTERY_STATE_MACHINES);
                return null;
            }
            if (DBG) {
            Log.d(TAG, "Creating a new state machine for " + device);
            }
            sm = BatteryStateMachine.make(device, this, mStateMachinesThread.getLooper());
            mStateMachines.put(device, sm);
            return sm;
@@ -473,9 +454,7 @@ public class BatteryService extends ProfileService {
     */
    @VisibleForTesting
    void bondStateChanged(BluetoothDevice device, int bondState) {
        if (DBG) {
        Log.d(TAG, "Bond state changed for device: " + device + " state: " + bondState);
        }
        // Remove state machine if the bonding for a device is removed
        if (bondState != BluetoothDevice.BOND_NONE) {
            return;
+2 −7
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import java.util.UUID;
 * It manages Battery service of a BLE device
 */
public class BatteryStateMachine extends StateMachine {
    private static final boolean DBG = false;
    private static final String TAG = "BatteryStateMachine";

    static final UUID GATT_BATTERY_SERVICE_UUID =
@@ -262,16 +261,12 @@ public class BatteryStateMachine extends StateMachine {

    @Override
    protected void log(String msg) {
        if (DBG) {
        super.log(msg);
    }
    }

    static void log(String tag, String msg) {
        if (DBG) {
        Log.d(tag, msg);
    }
    }

    @VisibleForTesting
    class Disconnected extends State {
+1 −3
Original line number Diff line number Diff line
@@ -497,8 +497,6 @@ class BaseData {
    }

    static void log(String msg) {
        if (BassConstants.BASS_DBG) {
        Log.d(TAG, msg);
    }
}
}
+8 −25
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ import java.util.concurrent.ConcurrentHashMap;
 * Broacast Assistant Scan Service
 */
public class BassClientService extends ProfileService {
    private static final boolean DBG = true;
    private static final String TAG = BassClientService.class.getSimpleName();
    private static final int MAX_BASS_CLIENT_STATE_MACHINES = 10;
    private static final int MAX_ACTIVE_SYNCED_SOURCES_NUM = 4;
@@ -381,9 +380,7 @@ public class BassClientService extends ProfileService {

    @Override
    public void start() {
        if (DBG) {
        Log.d(TAG, "start()");
        }
        if (sService != null) {
            throw new IllegalStateException("start() called twice");
        }
@@ -415,9 +412,7 @@ public class BassClientService extends ProfileService {

    @Override
    public void stop() {
        if (DBG) {
        Log.d(TAG, "stop()");
        }

        mUnicastSourceStreamStatus = Optional.empty();

@@ -530,9 +525,7 @@ public class BassClientService extends ProfileService {
    }

    private static synchronized void setBassClientService(BassClientService instance) {
        if (DBG) {
        Log.d(TAG, "setBassClientService(): set to: " + instance);
        }
        sService = instance;
    }

@@ -1056,9 +1049,7 @@ public class BassClientService extends ProfileService {
     * @return true if BAss profile successfully connected, false otherwise
     */
    public boolean connect(BluetoothDevice device) {
        if (DBG) {
        Log.d(TAG, "connect(): " + device);
        }
        if (device == null) {
            Log.e(TAG, "connect: device is null");
            return false;
@@ -1086,9 +1077,7 @@ public class BassClientService extends ProfileService {
     * @return true if Bass client profile successfully disconnected, false otherwise
     */
    public boolean disconnect(BluetoothDevice device) {
        if (DBG) {
        Log.d(TAG, "disconnect(): " + device);
        }
        if (device == null) {
            Log.e(TAG, "disconnect: device is null");
            return false;
@@ -1220,9 +1209,7 @@ public class BassClientService extends ProfileService {
     * @return true if connectionPolicy is set, false on error
     */
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        if (DBG) {
        Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        }
        boolean setSuccessfully =
                mDatabaseManager.setProfileConnectionPolicy(device,
                        BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT, connectionPolicy);
@@ -1858,15 +1845,11 @@ public class BassClientService extends ProfileService {
    }

    static void log(String msg) {
        if (BassConstants.BASS_DBG) {
        Log.d(TAG, msg);
    }
    }

    private void stopSourceReceivers(int broadcastId, boolean store) {
        if (DBG) {
        Log.d(TAG, "stopSourceReceivers(), broadcastId: " + broadcastId + ", store: " + store);
        }

        if (store && !mPausedBroadcastSinks.isEmpty()) {
            Log.w(TAG, "stopSourceReceivers(), paused broadcast sinks are replaced");
+1 −3
Original line number Diff line number Diff line
@@ -2241,10 +2241,8 @@ public class BassClientStateMachine extends StateMachine {

    @Override
    protected void log(String msg) {
        if (BassConstants.BASS_DBG) {
        super.log(msg);
    }
    }

    private static void logByteArray(String prefix, byte[] value, int offset, int count) {
        StringBuilder builder = new StringBuilder(prefix);
Loading