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

Commit e626a77a authored by Chelsea Hao's avatar Chelsea Hao Committed by Android (Google) Code Review
Browse files

Merge "[Audiosharing] Add log for debugging." into main

parents bf38bed8 89df32b4
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -75,6 +75,10 @@ public class AudioStreamMediaService extends Service {
                public void onSourceLost(int broadcastId) {
                    super.onSourceLost(broadcastId);
                    if (broadcastId == mBroadcastId) {
                        Log.d(TAG, "onSourceLost() : stopSelf");
                        if (mNotificationManager != null) {
                            mNotificationManager.cancel(NOTIFICATION_ID);
                        }
                        stopSelf();
                    }
                }
@@ -86,6 +90,10 @@ public class AudioStreamMediaService extends Service {
                            && mAudioStreamsHelper.getAllConnectedSources().stream()
                                    .map(BluetoothLeBroadcastReceiveState::getBroadcastId)
                                    .noneMatch(id -> id == mBroadcastId)) {
                        Log.d(TAG, "onSourceRemoved() : stopSelf");
                        if (mNotificationManager != null) {
                            mNotificationManager.cancel(NOTIFICATION_ID);
                        }
                        stopSelf();
                    }
                }
@@ -96,6 +104,10 @@ public class AudioStreamMediaService extends Service {
                @Override
                public void onBluetoothStateChanged(int bluetoothState) {
                    if (BluetoothAdapter.STATE_OFF == bluetoothState) {
                        Log.d(TAG, "onBluetoothStateChanged() : stopSelf");
                        if (mNotificationManager != null) {
                            mNotificationManager.cancel(NOTIFICATION_ID);
                        }
                        stopSelf();
                    }
                }
@@ -120,6 +132,10 @@ public class AudioStreamMediaService extends Service {
                                        });
                    }
                    if (mDevices == null || mDevices.isEmpty()) {
                        Log.d(TAG, "onProfileConnectionStateChanged() : stopSelf");
                        if (mNotificationManager != null) {
                            mNotificationManager.cancel(NOTIFICATION_ID);
                        }
                        stopSelf();
                    }
                }
@@ -246,21 +262,27 @@ public class AudioStreamMediaService extends Service {

    @Override
    public void onDestroy() {
        Log.d(TAG, "onDestroy()");
        super.onDestroy();

        if (!AudioSharingUtils.isFeatureEnabled()) {
            Log.d(TAG, "onDestroy() : skip due to feature not enabled");
            return;
        }
        if (mLocalBtManager != null) {
            Log.d(TAG, "onDestroy() : unregister mBluetoothCallback");
            mLocalBtManager.getEventManager().unregisterCallback(mBluetoothCallback);
        }
        if (mLeBroadcastAssistant != null) {
            Log.d(TAG, "onDestroy() : unregister mBroadcastAssistantCallback");
            mLeBroadcastAssistant.unregisterServiceCallBack(mBroadcastAssistantCallback);
        }
        if (mVolumeControl != null) {
            Log.d(TAG, "onDestroy() : unregister mVolumeControlCallback");
            mVolumeControl.unregisterCallback(mVolumeControlCallback);
        }
        if (mLocalSession != null) {
            Log.d(TAG, "onDestroy() : release mLocalSession");
            mLocalSession.release();
            mLocalSession = null;
        }
@@ -273,6 +295,9 @@ public class AudioStreamMediaService extends Service {
        mBroadcastId = intent != null ? intent.getIntExtra(BROADCAST_ID, -1) : -1;
        if (mBroadcastId == -1) {
            Log.w(TAG, "Invalid broadcast ID. Service will not start.");
            if (mNotificationManager != null) {
                mNotificationManager.cancel(NOTIFICATION_ID);
            }
            stopSelf();
            return START_NOT_STICKY;
        }
@@ -282,6 +307,9 @@ public class AudioStreamMediaService extends Service {
        }
        if (mDevices == null || mDevices.isEmpty()) {
            Log.w(TAG, "No device. Service will not start.");
            if (mNotificationManager != null) {
                mNotificationManager.cancel(NOTIFICATION_ID);
            }
            stopSelf();
            return START_NOT_STICKY;
        }