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

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

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

parents 19382542 938cad30
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -401,6 +401,12 @@ public class HealthService extends ProfileService {
            IBluetoothHealthCallback callback) {
            IBluetoothHealthCallback callback) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM,
        enforceCallingOrSelfPermission(BLUETOOTH_PERM,
                "Need BLUETOOTH permission");
                "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 (mApps.get(config) != null) {
            if (DBG) Log.d(TAG, "Config has already been registered");
            if (DBG) Log.d(TAG, "Config has already been registered");
            return false;
            return false;
+19 −0
Original line number Original line 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));
    }

}