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

Commit 66ac6f85 authored by Tej Singh's avatar Tej Singh
Browse files

Log: Bluetooth Connections

Logs bluetooth connections.
Note: This change is cherry picked from aosp: go/aog/647339.

Bug: b/72320489
Bug: b/74457175
Test: verified logs appear in adb logcat -b stats
Merged-In: Ibd082c6bb1e39e2453d59b5a0d8c6ba04047daaa
Change-Id: Ibd082c6bb1e39e2453d59b5a0d8c6ba04047daaa
parent fb3f9770
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -40,8 +40,10 @@ import android.content.IntentFilter;
import android.os.ParcelUuid;
import android.os.ParcelUuid;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserHandle;
import android.provider.Settings.Secure;
import android.util.Log;
import android.util.Log;
import android.util.Pair;
import android.util.Pair;
import android.util.StatsLog;


import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties;
import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties;
@@ -524,6 +526,11 @@ class AdapterProperties {
        Log.d(TAG,
        Log.d(TAG,
                "PROFILE_CONNECTION_STATE_CHANGE: profile=" + profile + ", device=" + device + ", "
                "PROFILE_CONNECTION_STATE_CHANGE: profile=" + profile + ", device=" + device + ", "
                        + prevState + " -> " + state);
                        + prevState + " -> " + state);
        String ssaid = Secure.getString(mService.getContentResolver(), Secure.ANDROID_ID);
        String combined = ssaid + device.getAddress();
        int obfuscated_id = combined.hashCode() & 0xFFFF; // Last two bytes only
        StatsLog.write(StatsLog.BLUETOOTH_CONNECTION_STATE_CHANGED,
                state, obfuscated_id, profile);
        if (!isNormalStateTransition(prevState, state)) {
        if (!isNormalStateTransition(prevState, state)) {
            Log.w(TAG,
            Log.w(TAG,
                    "PROFILE_CONNECTION_STATE_CHANGE: unexpected transition for profile=" + profile
                    "PROFILE_CONNECTION_STATE_CHANGE: unexpected transition for profile=" + profile