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

Commit 0d7a5d60 authored by Wei Wang's avatar Wei Wang
Browse files

Merge diffs from API review comments(2/2).

Change-Id: I7316ec4fe134268927b27c14e421e6e3fc31b59f
parent 6934f9c5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -3,19 +3,19 @@ package com.android.bluetooth.gatt;

import android.annotation.Nullable;
import android.bluetooth.le.AdvertisementData;
import android.bluetooth.le.BluetoothLeAdvertiseSettings;
import android.bluetooth.le.AdvertiseSettings;

/**
 * @hide
 */
class AdvertiseClient {
    int clientIf;
    BluetoothLeAdvertiseSettings settings;
    AdvertiseSettings settings;
    AdvertisementData advertiseData;
    @Nullable
    AdvertisementData scanResponse;

    AdvertiseClient(int clientIf, BluetoothLeAdvertiseSettings settings, AdvertisementData data,
    AdvertiseClient(int clientIf, AdvertiseSettings settings, AdvertisementData data,
            AdvertisementData scanResponse) {
        this.clientIf = clientIf;
        this.settings = settings;
+6 −6
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ import android.bluetooth.IBluetoothGattCallback;
import android.bluetooth.IBluetoothGattServerCallback;
import android.bluetooth.le.AdvertiseCallback;
import android.bluetooth.le.AdvertisementData;
import android.bluetooth.le.BluetoothLeAdvertiseSettings;
import android.bluetooth.le.BluetoothLeScanSettings;
import android.bluetooth.le.AdvertiseSettings;
import android.bluetooth.le.ScanSettings;
import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanResult;
import android.content.Intent;
@@ -345,7 +345,7 @@ public class GattService extends ProfileService {
        }

        @Override
        public void startScanWithFilters(int appIf, boolean isServer, BluetoothLeScanSettings settings,
        public void startScanWithFilters(int appIf, boolean isServer, ScanSettings settings,
                List<ScanFilter> filters) {
            GattService service = getService();
            if (service == null) return;
@@ -571,7 +571,7 @@ public class GattService extends ProfileService {
        @Override
        public void startMultiAdvertising(int clientIf, AdvertisementData advertiseData,
                AdvertisementData scanResponse,
                BluetoothLeAdvertiseSettings settings) {
                AdvertiseSettings settings) {
            GattService service = getService();
            if (service == null) return;
            service.startMultiAdvertising(clientIf, advertiseData, scanResponse, settings);
@@ -1241,7 +1241,7 @@ public class GattService extends ProfileService {
        configureScanParams();
    }

    void startScanWithFilters(int appIf, boolean isServer, BluetoothLeScanSettings settings,
    void startScanWithFilters(int appIf, boolean isServer, ScanSettings settings,
            List<ScanFilter> filters) {
        if (DBG) Log.d(TAG, "start scan with filters " + filters.size());
        enforceAdminPermission();
@@ -1523,7 +1523,7 @@ public class GattService extends ProfileService {
    }

    void startMultiAdvertising(int clientIf, AdvertisementData advertiseData,
            AdvertisementData scanResponse, BluetoothLeAdvertiseSettings settings) {
            AdvertisementData scanResponse, AdvertiseSettings settings) {
        enforceAdminPermission();
        Message message = mStateMachine.obtainMessage(GattServiceStateMachine.START_ADVERTISING);
        message.obj = new AdvertiseClient(clientIf, settings, advertiseData, scanResponse);
+14 −14
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ package com.android.bluetooth.gatt;

import android.bluetooth.le.AdvertiseCallback;
import android.bluetooth.le.AdvertisementData;
import android.bluetooth.le.BluetoothLeAdvertiseSettings;
import android.bluetooth.le.AdvertiseSettings;
import android.bluetooth.le.ScanFilter;
import android.os.Message;
import android.os.ParcelUuid;
@@ -440,15 +440,15 @@ final class GattServiceStateMachine extends StateMachine {
    }

    // Convert settings tx power level to stack tx power level.
    private int getTxPowerLevel(BluetoothLeAdvertiseSettings settings) {
    private int getTxPowerLevel(AdvertiseSettings settings) {
        switch (settings.getTxPowerLevel()) {
            case BluetoothLeAdvertiseSettings.ADVERTISE_TX_POWER_ULTRA_LOW:
            case AdvertiseSettings.ADVERTISE_TX_POWER_ULTRA_LOW:
                return ADVERTISING_TX_POWER_MIN;
            case BluetoothLeAdvertiseSettings.ADVERTISE_TX_POWER_LOW:
            case AdvertiseSettings.ADVERTISE_TX_POWER_LOW:
                return ADVERTISING_TX_POWER_LOW;
            case BluetoothLeAdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM:
            case AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM:
                return ADVERTISING_TX_POWER_MID;
            case BluetoothLeAdvertiseSettings.ADVERTISE_TX_POWER_HIGH:
            case AdvertiseSettings.ADVERTISE_TX_POWER_HIGH:
                return ADVERTISING_TX_POWER_UPPER;
            default:
                // Shouldn't happen, just in case.
@@ -457,13 +457,13 @@ final class GattServiceStateMachine extends StateMachine {
    }

    // Convert advertising event type to stack advertising event type.
    private int getAdvertisingEventType(BluetoothLeAdvertiseSettings settings) {
    private int getAdvertisingEventType(AdvertiseSettings settings) {
        switch (settings.getType()) {
            case BluetoothLeAdvertiseSettings.ADVERTISE_TYPE_CONNECTABLE:
            case AdvertiseSettings.ADVERTISE_TYPE_CONNECTABLE:
                return ADVERTISING_EVENT_TYPE_CONNECTABLE;
            case BluetoothLeAdvertiseSettings.ADVERTISE_TYPE_SCANNABLE:
            case AdvertiseSettings.ADVERTISE_TYPE_SCANNABLE:
                return ADVERTISING_EVENT_TYPE_SCANNABLE;
            case BluetoothLeAdvertiseSettings.ADVERTISE_TYPE_NON_CONNECTABLE:
            case AdvertiseSettings.ADVERTISE_TYPE_NON_CONNECTABLE:
                return ADVERTISING_EVENT_TYPE_NON_CONNECTABLE;
            default:
                // Should't happen, just in case.
@@ -472,13 +472,13 @@ final class GattServiceStateMachine extends StateMachine {
    }

    // Convert advertising milliseconds to advertising units(one unit is 0.625 millisecond).
    private long getAdvertisingIntervalUnit(BluetoothLeAdvertiseSettings settings) {
    private long getAdvertisingIntervalUnit(AdvertiseSettings settings) {
        switch (settings.getMode()) {
            case BluetoothLeAdvertiseSettings.ADVERTISE_MODE_LOW_POWER:
            case AdvertiseSettings.ADVERTISE_MODE_LOW_POWER:
                return millsToUnit(ADVERTISING_INTERVAL_LOW_MILLS);
            case BluetoothLeAdvertiseSettings.ADVERTISE_MODE_BALANCED:
            case AdvertiseSettings.ADVERTISE_MODE_BALANCED:
                return millsToUnit(ADVERTISING_INTERVAL_MEDIUM_MILLS);
            case BluetoothLeAdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY:
            case AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY:
                return millsToUnit(ADVERTISING_INTERVAL_HIGH_MILLS);
            default:
                // Shouldn't happen, just in case.
+4 −4
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package com.android.bluetooth.gatt;

import android.bluetooth.le.BluetoothLeScanSettings;
import android.bluetooth.le.ScanSettings;
import android.bluetooth.le.ScanFilter;

import java.util.List;
@@ -43,7 +43,7 @@ import java.util.UUID;
    boolean isServer;
    UUID[] uuids;
    int scanWindow, scanInterval;
    BluetoothLeScanSettings settings;
    ScanSettings settings;
    List<ScanFilter> filters;

    ScanClient(int appIf, boolean isServer) {
@@ -58,14 +58,14 @@ import java.util.UUID;
        this(appIf, isServer, uuids, scanWindow, scanInterval, null, null);
    }

    ScanClient(int appIf, boolean isServer, BluetoothLeScanSettings settings,
    ScanClient(int appIf, boolean isServer, ScanSettings settings,
            List<ScanFilter> filters) {
        this(appIf, isServer, new UUID[0], LE_SCAN_WINDOW_MS, LE_SCAN_INTERVAL_MS,
                settings, filters);
    }

    private ScanClient(int appIf, boolean isServer, UUID[] uuids, int scanWindow, int scanInterval,
            BluetoothLeScanSettings settings, List<ScanFilter> filters) {
            ScanSettings settings, List<ScanFilter> filters) {
        this.appIf = appIf;
        this.isServer = isServer;
        this.uuids = uuids;