1e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang/*
2e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang * Copyright (C) 2014 The Android Open Source Project
3e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang *
4e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang * Licensed under the Apache License, Version 2.0 (the "License");
5e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang * you may not use this file except in compliance with the License.
6e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang * You may obtain a copy of the License at
7e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang *
8e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang *      http://www.apache.org/licenses/LICENSE-2.0
9e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang *
10e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang * Unless required by applicable law or agreed to in writing, software
11e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang * distributed under the License is distributed on an "AS IS" BASIS,
12e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang * See the License for the specific language governing permissions and
14e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang * limitations under the License.
15e65500db39422398f3b87c4f340e66fdfec7e328Wei Wang */
161a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang
171a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wangpackage com.android.bluetooth.gatt;
181a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang
19ccd5f131d51ef8019c87628b992bc67cbbcc2ea6Wei Wangimport android.annotation.Nullable;
20361e580eb6c07759cdd775ed57902839ff4bfe90Andre Eisenbachimport android.bluetooth.le.AdvertiseData;
2180e7d011fdb511a6583258458e97821176866baaWei Wangimport android.bluetooth.le.AdvertiseSettings;
221a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang
2327bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wangimport java.util.Objects;
2427bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang
251a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang/**
2627bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang * Helper class that represents a client for Bluetooth LE advertise operations.
2727bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang *
281a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang * @hide
291a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang */
301a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wangclass AdvertiseClient {
311a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang    int clientIf;
32039bf1606bddb3794fd6aa9adee704733f89544fWei Wang    // Associated application died.
33039bf1606bddb3794fd6aa9adee704733f89544fWei Wang    boolean appDied;
3480e7d011fdb511a6583258458e97821176866baaWei Wang    AdvertiseSettings settings;
35361e580eb6c07759cdd775ed57902839ff4bfe90Andre Eisenbach    AdvertiseData advertiseData;
36ccd5f131d51ef8019c87628b992bc67cbbcc2ea6Wei Wang    @Nullable
37361e580eb6c07759cdd775ed57902839ff4bfe90Andre Eisenbach    AdvertiseData scanResponse;
381a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang
3927bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    /**
4027bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang     * @param clientIf - Identifier of the client.
4127bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang     */
42039bf1606bddb3794fd6aa9adee704733f89544fWei Wang    AdvertiseClient(int clientIf) {
4327bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang        this.clientIf = clientIf;
4427bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    }
4527bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang
4627bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    /**
4727bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang     * @param clientIf - Identifier of the client.
4827bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang     * @param settings - Settings for the advertising.
4927bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang     * @param advertiseData - Advertise data broadcasted over the air.
5027bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang     * @param scanResponse - Response of scan request, could be null.
5127bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang     */
5227bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    AdvertiseClient(int clientIf, AdvertiseSettings settings, AdvertiseData advertiseData,
53361e580eb6c07759cdd775ed57902839ff4bfe90Andre Eisenbach            AdvertiseData scanResponse) {
541a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang        this.clientIf = clientIf;
551a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang        this.settings = settings;
5627bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang        this.advertiseData = advertiseData;
57ccd5f131d51ef8019c87628b992bc67cbbcc2ea6Wei Wang        this.scanResponse = scanResponse;
581a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang    }
5927bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang
6027bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    @Override
6127bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    public boolean equals(Object obj) {
6227bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang        if (this == obj) {
6327bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang            return true;
6427bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang        }
6527bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang        if (obj == null || getClass() != obj.getClass()) {
6627bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang            return false;
6727bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang        }
6827bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang        AdvertiseClient other = (AdvertiseClient) obj;
6927bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang        return clientIf == other.clientIf;
7027bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    }
7127bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang
7227bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    @Override
7327bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    public int hashCode() {
7427bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang        return Objects.hash(clientIf);
7527bd5f277ccf471f2fa9cd9151a2a226b51bc825Wei Wang    }
761a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang}
77