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

Commit f174e019 authored by David Duarte's avatar David Duarte Committed by Automerger Merge Worker
Browse files

Merge "[DCK] Fix regression breaking IRK scanning" am: 6aa34391 am: 26b652c2 am: 7a1796ee

parents 07a06031 7a1796ee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ public final class ScanFilter implements Parcelable {
            dest.writeInt(mAddressType);
            dest.writeInt(mIrk == null ? 0 : 1);
            if (mIrk != null) {
                dest.writeByteArray(Arrays.copyOfRange(mIrk, 0, 16 + 1));
                dest.writeByteArray(Arrays.copyOfRange(mIrk, 0, 16));
            }
        }

+46 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.bluetooth.le;

import android.bluetooth.BluetoothDevice;
import android.os.Parcel;
import android.test.suitebuilder.annotation.SmallTest;

import junit.framework.TestCase;

public class ScanFilterTest extends TestCase {
    @SmallTest
    public void testIrkFilterParcelable() {
        // arrange: an IRK filter
        Parcel parcel = Parcel.obtain();
        var filter =
                new ScanFilter.Builder()
                        .setDeviceAddress(
                                "11:22:33:44:55:66",
                                BluetoothDevice.ADDRESS_TYPE_PUBLIC,
                                new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})
                        .build();

        // act: serialize and deserialize
        filter.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);
        ScanFilter filterFromParcel = ScanFilter.CREATOR.createFromParcel(parcel);

        // assert: no change
        assertEquals(filter, filterFromParcel);
    }
}