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

Commit 454274c6 authored by Kihong Seong's avatar Kihong Seong
Browse files

[BluetoothMetrics] Adding Counter Metrics for running in foreground when

performing server connect

Adding counter metrics for GattService.serverConnect to count when the
app calling the API is running in foreground.

Bug: 280070905
Test: atest BluetoothInstrumentationTests
Change-Id: I2d02a696056c3379d8df9b907c49d8f7439a7e2f
parent e02e8cfe
Loading
Loading
Loading
Loading
+22 −0
Original line number Original line Diff line number Diff line
@@ -4561,6 +4561,28 @@ public class GattService extends ProfileService {
        if (DBG) {
        if (DBG) {
            Log.d(TAG, "serverConnect() - address=" + address);
            Log.d(TAG, "serverConnect() - address=" + address);
        }
        }

        int importance = mActivityManager.getUidImportance(attributionSource.getUid());
        if (importance == IMPORTANCE_FOREGROUND_SERVICE) {
            MetricsLogger.getInstance()
                    .count(
                            isDirect
                                    ? BluetoothProtoEnums
                                            .GATT_SERVER_CONNECT_IS_DIRECT_IN_FOREGROUND
                                    : BluetoothProtoEnums
                                            .GATT_SERVER_CONNECT_IS_AUTOCONNECT_IN_FOREGROUND,
                            1);
        } else {
            MetricsLogger.getInstance()
                    .count(
                            isDirect
                                    ? BluetoothProtoEnums
                                            .GATT_SERVER_CONNECT_IS_DIRECT_NOT_IN_FOREGROUND
                                    : BluetoothProtoEnums
                                            .GATT_SERVER_CONNECT_IS_AUTOCONNECT_NOT_IN_FOREGROUND,
                            1);
        }

        mNativeInterface.gattServerConnect(serverIf, address, isDirect, transport);
        mNativeInterface.gattServerConnect(serverIf, address, isDirect, transport);
    }
    }