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

Commit 34c2176a authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Metrics: Log A2DP playback related metrics through StatsLog"

parents 11a891e3 161a3e3e
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import android.content.IntentFilter;
import android.media.AudioManager;
import android.media.AudioManager;
import android.os.HandlerThread;
import android.os.HandlerThread;
import android.util.Log;
import android.util.Log;
import android.util.StatsLog;


import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
@@ -810,6 +811,24 @@ public class A2dpService extends ProfileService {
     */
     */
    void codecConfigUpdated(BluetoothDevice device, BluetoothCodecStatus codecStatus,
    void codecConfigUpdated(BluetoothDevice device, BluetoothCodecStatus codecStatus,
                            boolean sameAudioFeedingParameters) {
                            boolean sameAudioFeedingParameters) {
        // Log codec config and capability metrics
        BluetoothCodecConfig codecConfig = codecStatus.getCodecConfig();
        StatsLog.write(StatsLog.BLUETOOTH_A2DP_CODEC_CONFIG_CHANGED,
                mAdapterService.obfuscateAddress(device), codecConfig.getCodecType(),
                codecConfig.getCodecPriority(), codecConfig.getSampleRate(),
                codecConfig.getBitsPerSample(), codecConfig.getChannelMode(),
                codecConfig.getCodecSpecific1(), codecConfig.getCodecSpecific2(),
                codecConfig.getCodecSpecific3(), codecConfig.getCodecSpecific4());
        BluetoothCodecConfig[] codecCapabilities = codecStatus.getCodecsSelectableCapabilities();
        for (BluetoothCodecConfig codecCapability : codecCapabilities) {
            StatsLog.write(StatsLog.BLUETOOTH_A2DP_CODEC_CAPABILITY_CHANGED,
                    mAdapterService.obfuscateAddress(device), codecCapability.getCodecType(),
                    codecCapability.getCodecPriority(), codecCapability.getSampleRate(),
                    codecCapability.getBitsPerSample(), codecCapability.getChannelMode(),
                    codecConfig.getCodecSpecific1(), codecConfig.getCodecSpecific2(),
                    codecConfig.getCodecSpecific3(), codecConfig.getCodecSpecific4());
        }

        broadcastCodecConfig(device, codecStatus);
        broadcastCodecConfig(device, codecStatus);


        // Inform the Audio Service about the codec configuration change,
        // Inform the Audio Service about the codec configuration change,
@@ -866,6 +885,8 @@ public class A2dpService extends ProfileService {
            mActiveDevice = device;
            mActiveDevice = device;
        }
        }


        StatsLog.write(StatsLog.BLUETOOTH_ACTIVE_DEVICE_CHANGED, BluetoothProfile.A2DP,
                mAdapterService.obfuscateAddress(device));
        Intent intent = new Intent(BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED);
        Intent intent = new Intent(BluetoothA2dp.ACTION_ACTIVE_DEVICE_CHANGED);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
+2 −1
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ import android.content.Intent;
import android.os.Looper;
import android.os.Looper;
import android.os.Message;
import android.os.Message;
import android.util.Log;
import android.util.Log;
import android.util.StatsLog;


import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
@@ -672,7 +673,7 @@ final class A2dpStateMachine extends StateMachine {
    private void broadcastAudioState(int newState, int prevState) {
    private void broadcastAudioState(int newState, int prevState) {
        log("A2DP Playing state : device: " + mDevice + " State:" + audioStateToString(prevState)
        log("A2DP Playing state : device: " + mDevice + " State:" + audioStateToString(prevState)
                + "->" + audioStateToString(newState));
                + "->" + audioStateToString(newState));

        StatsLog.write(StatsLog.BLUETOOTH_A2DP_PLAYBACK_STATE_CHANGED, newState);
        Intent intent = new Intent(BluetoothA2dp.ACTION_PLAYING_STATE_CHANGED);
        Intent intent = new Intent(BluetoothA2dp.ACTION_PLAYING_STATE_CHANGED);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
        intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState);
        intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState);
+3 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import android.media.AudioManager;
import android.os.HandlerThread;
import android.os.HandlerThread;
import android.os.ParcelUuid;
import android.os.ParcelUuid;
import android.util.Log;
import android.util.Log;
import android.util.StatsLog;


import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
@@ -605,6 +606,8 @@ public class HearingAidService extends ProfileService {
            Log.d(TAG, "reportActiveDevice(" + device + ")");
            Log.d(TAG, "reportActiveDevice(" + device + ")");
        }
        }


        StatsLog.write(StatsLog.BLUETOOTH_ACTIVE_DEVICE_CHANGED, BluetoothProfile.HEARING_AID,
                mAdapterService.obfuscateAddress(device));
        Intent intent = new Intent(BluetoothHearingAid.ACTION_ACTIVE_DEVICE_CHANGED);
        Intent intent = new Intent(BluetoothHearingAid.ACTION_ACTIVE_DEVICE_CHANGED);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
+3 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserHandle;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccount;
import android.util.Log;
import android.util.Log;
import android.util.StatsLog;


import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.BluetoothMetricsProto;
import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
@@ -1699,6 +1700,8 @@ public class HeadsetService extends ProfileService {


    private void broadcastActiveDevice(BluetoothDevice device) {
    private void broadcastActiveDevice(BluetoothDevice device) {
        logD("broadcastActiveDevice: " + device);
        logD("broadcastActiveDevice: " + device);
        StatsLog.write(StatsLog.BLUETOOTH_ACTIVE_DEVICE_CHANGED, BluetoothProfile.HEADSET,
                mAdapterService.obfuscateAddress(device));
        Intent intent = new Intent(BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED);
        Intent intent = new Intent(BluetoothHeadset.ACTION_ACTIVE_DEVICE_CHANGED);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT