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

Commit 5c5052d3 authored by Ajay Kumar's avatar Ajay Kumar Committed by Gerrit - the friendly Code Review server
Browse files

Bluetooth: Enable debug logs to debug app level issues

Enable debug logs to debug profile level issues like
start timeout etc

Change-Id: Ifb724a37e6a77dee7de54825a19e4761b2373465
parent da174748
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -333,7 +333,7 @@ public class AdapterService extends Service {
                doUpdate=true;
            }
        }
        debugLog("onProfileServiceStateChange() serviceName=" + serviceName
        Log.w(TAG, "onProfileServiceStateChange() serviceName=" + serviceName
            + ", state=" + state +", doUpdate=" + doUpdate);

        if (!doUpdate) {
@@ -379,13 +379,13 @@ public class AdapterService extends Service {
                        continue;
                    }
                    if (BluetoothAdapter.STATE_OFF != entry.getValue()) {
                        Log.d(TAG,"onProfileServiceStateChange() - Profile still running: "
                        Log.w(TAG,"onProfileServiceStateChange() - Profile still running: "
                            + entry.getKey());
                        return;
                    }
                }
            }
            debugLog("onProfileServiceStateChange() - All profile services stopped...");
            Log.w(TAG,"onProfileServiceStateChange() - All profile services stopped...");
            //Send message to state machine
            mProfilesStarted=false;
            mAdapterStateMachine.sendMessage(mAdapterStateMachine.obtainMessage(AdapterState.BREDR_STOPPED));
@@ -399,18 +399,18 @@ public class AdapterService extends Service {
                    Map.Entry<String,Integer> entry = i.next();
                    debugLog("Service: " + entry.getKey());
                    if (entry.getKey().equals("com.android.bluetooth.gatt.GattService")) {
                        debugLog("Skip GATT service - already started before");
                        Log.w(TAG, "Skip GATT service - already started before");
                        continue;
                    }

                    if (BluetoothAdapter.STATE_ON != entry.getValue()) {
                        debugLog("onProfileServiceStateChange() - Profile still not running:"
                        Log.w(TAG, "onProfileServiceStateChange() - Profile still not running:"
                              + entry.getKey());
                        return;
                    }
                }
            }
            debugLog("onProfileServiceStateChange() - All profile services started.");
            Log.w(TAG,"onProfileServiceStateChange() - All profile services started.");
            mProfilesStarted=true;
            //Send message to state machine
            mAdapterStateMachine.sendMessage(mAdapterStateMachine.obtainMessage(AdapterState.BREDR_STARTED));
@@ -449,7 +449,7 @@ public class AdapterService extends Service {
    }
    public boolean onUnbind(Intent intent) {
        if (getState() == BluetoothAdapter.STATE_OFF) {
            debugLog("onUnbind, calling cleanup");
            Log.w(TAG, "onUnbind, calling cleanup");
            cleanup();
            return super.onUnbind(intent);
        }
@@ -489,7 +489,7 @@ public class AdapterService extends Service {
            //Startup all profile services
            setProfileServiceState(supportedProfileServices,BluetoothAdapter.STATE_ON);
        }else {
            debugLog("startCoreProfiles(): Profile Services alreay started");
            Log.w(TAG,"startCoreProfiles(): Profile Services alreay started");
            mAdapterStateMachine.sendMessage(mAdapterStateMachine.obtainMessage(AdapterState.BREDR_STARTED));
        }
    }
@@ -714,6 +714,7 @@ public class AdapterService extends Service {
            expectedCurrentState= BluetoothAdapter.STATE_ON;
            pendingState = BluetoothAdapter.STATE_TURNING_OFF;
        }
        Log.w(TAG, "Total profiles ="+ (services.length));

        for (int i=0; i <services.length;i++) {
            String serviceName = services[i].getName();
@@ -723,14 +724,14 @@ public class AdapterService extends Service {

            Integer serviceState = mProfileServicesState.get(serviceName);
            if(serviceState != null && serviceState != expectedCurrentState) {
                debugLog("setProfileServiceState() - Unable to "
                Log.w(TAG, "setProfileServiceState() - Unable to "
                    + (state == BluetoothAdapter.STATE_OFF ? "start" : "stop" )
                    + " service " + serviceName
                    + ". Invalid state: " + serviceState);
                continue;
            }

            debugLog("setProfileServiceState() - "
            Log.w(TAG, "setProfileServiceState() - "
                + (state == BluetoothAdapter.STATE_OFF ? "Stopping" : "Starting")
                + " service " + serviceName);

+2 −0
Original line number Diff line number Diff line
@@ -202,6 +202,7 @@ public abstract class ProfileService extends Service {
            if (DBG) log("start()");
            mStartError = !start();
            if (!mStartError) {
                Log.d(mName, " profile started successfully");
                notifyProfileServiceStateChanged(BluetoothAdapter.STATE_ON);
            } else {
                Log.e(mName, "Error starting profile. BluetoothAdapter is null");
@@ -213,6 +214,7 @@ public abstract class ProfileService extends Service {
        if (stop()) {
            if (DBG) log("stop()");
            stopSelf();
            Log.d(mName, " profile stopped successfully");
            notifyProfileServiceStateChanged(BluetoothAdapter.STATE_OFF);
        } else {
            Log.e(mName, "Unable to stop profile");