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

Commit 8f85510b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Revert "AdapterService: Remove unused local metric logger"" into main

parents 1f1a6668 0760a836
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -318,6 +318,8 @@ public class AdapterService extends Service {

    private volatile boolean mTestModeEnabled = false;

    private MetricsLogger mMetricsLogger;

    /** Handlers for incoming service calls */
    private AdapterServiceBinder mBinder;

@@ -636,6 +638,7 @@ public class AdapterService extends Service {
    private void init() {
        Log.d(TAG, "init()");
        Config.init(this);
        initMetricsLogger();
        mDeviceConfigListener.start();

        if (!Flags.fastBindToApp()) {
@@ -806,6 +809,23 @@ public class AdapterService extends Service {
        return mSilenceDeviceManager;
    }

    private boolean initMetricsLogger() {
        if (mMetricsLogger != null) {
            return false;
        }
        mMetricsLogger = MetricsLogger.getInstance();
        return mMetricsLogger.init(this);
    }

    private boolean closeMetricsLogger() {
        if (mMetricsLogger == null) {
            return false;
        }
        boolean result = mMetricsLogger.close();
        mMetricsLogger = null;
        return result;
    }

    /**
     * Log L2CAP CoC Server Connection Metrics
     *
@@ -858,6 +878,10 @@ public class AdapterService extends Service {
                socketAcceptanceLatencyMillis);
    }

    public void setMetricsLogger(MetricsLogger metricsLogger) {
        mMetricsLogger = metricsLogger;
    }

    /**
     * Log L2CAP CoC Client Connection Metrics
     *
@@ -1317,6 +1341,8 @@ public class AdapterService extends Service {
            return;
        }

        closeMetricsLogger();

        clearAdapterService(this);

        mCleaningUp = true;
+6 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ public class AdapterServiceRestartTest {
    private @Mock IBluetoothCallback mIBluetoothCallback;
    private @Mock Binder mBinder;
    private @Mock android.app.Application mApplication;
    private @Mock MetricsLogger mMockMetricsLogger;
    private @Mock AdapterNativeInterface mNativeInterface;
    private @Mock BluetoothKeystoreNativeInterface mKeystoreNativeInterface;
    private @Mock BluetoothQualityReportNativeInterface mQualityNativeInterface;
@@ -223,9 +224,14 @@ public class AdapterServiceRestartTest {
        doReturn(Process.BLUETOOTH_UID).when(mMockPackageManager)
                .getPackageUidAsUser(any(), anyInt(), anyInt());

        when(mMockMetricsLogger.init(any())).thenReturn(true);
        when(mMockMetricsLogger.close()).thenReturn(true);

        AdapterServiceTest.configureEnabledProfiles();
        Config.init(mMockContext);

        mAdapterService.setMetricsLogger(mMockMetricsLogger);

        // Attach a context to the service for permission checks.
        mAdapterService.attach(mMockContext, null, null, null, mApplication, null);
        mAdapterService.onCreate();
+6 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ public class AdapterServiceTest {
    private @Mock IBluetoothCallback mIBluetoothCallback;
    private @Mock Binder mBinder;
    private @Mock android.app.Application mApplication;
    private @Mock MetricsLogger mMockMetricsLogger;
    private @Mock AdapterNativeInterface mNativeInterface;
    private @Mock BluetoothKeystoreNativeInterface mKeystoreNativeInterface;
    private @Mock BluetoothQualityReportNativeInterface mQualityNativeInterface;
@@ -311,9 +312,14 @@ public class AdapterServiceTest {
        when(mMockService.getName()).thenReturn("Service1");
        when(mMockService2.getName()).thenReturn("Service2");

        when(mMockMetricsLogger.init(any())).thenReturn(true);
        when(mMockMetricsLogger.close()).thenReturn(true);

        configureEnabledProfiles();
        Config.init(mMockContext);

        mAdapterService.setMetricsLogger(mMockMetricsLogger);

        // Attach a context to the service for permission checks.
        mAdapterService.attach(mMockContext, null, null, null, mApplication, null);
        mAdapterService.onCreate();