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

Commit 868c01a6 authored by Ajay Panicker's avatar Ajay Panicker Committed by android-build-merger
Browse files

Merge "Protect against adding a null config for the BT health profile"

am: f8727080

Change-Id: I96dc9eb3b033518474700ef05942d1e8a18d645b
parents 57770075 f8727080
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -401,6 +401,12 @@ public class HealthService extends ProfileService {
            IBluetoothHealthCallback callback) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM,
                "Need BLUETOOTH permission");

        if (config == null) {
            Log.e(TAG, "Trying to use a null config for registration");
            return false;
        }

        if (mApps.get(config) != null) {
            if (DBG) Log.d(TAG, "Config has already been registered");
            return false;
+19 −0
Original line number Diff line number Diff line
package com.android.bluetooth.hdp;

import android.test.InstrumentationTestCase;

import junit.framework.Assert;

public class HealthServiceTest extends InstrumentationTestCase {

    public void testRegisterAppConfiguration() {
        HealthService testService = new HealthService();

        // Attach a context to the Health Service for permission checks
        testService.attach(getInstrumentation().getContext(), null, null, null, null, null);

        // Test registering a null config
        assertEquals(false, testService.registerAppConfiguration(null, null));
    }

}