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

Commit 33b8f26c authored by Matthew Xie's avatar Matthew Xie Committed by Android (Google) Code Review
Browse files

Merge "LE: Add peripheral role support (1/4)" into klp-dev

parents baa670ec 3b486eb5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1752,6 +1752,10 @@ public final class BluetoothAdapter {
        public void onReadRemoteRssi(String address, int rssi, int status) {
            // no op
        }

        public void onListen(int status) {
            // no op
        }
    }

}
+65 −0
Original line number Diff line number Diff line
@@ -553,6 +553,14 @@ public final class BluetoothGatt implements BluetoothProfile {
                    Log.w(TAG, "Unhandled exception in callback", ex);
                }
            }

            /**
             * Listen command status callback
             * @hide
             */
            public void onListen(int status) {
                if (DBG) Log.d(TAG, "onListen() - status=" + status);
            }
        };

    /*package*/ BluetoothGatt(Context context, IBluetoothGatt iGatt, BluetoothDevice device) {
@@ -685,6 +693,63 @@ public final class BluetoothGatt implements BluetoothProfile {
        return true;
    }

   /**
     * Starts or stops sending of advertisement packages to listen for connection
     * requests from a central devices.
     *
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
     *
     * @param start Start or stop advertising
     */
    /*package*/ void listen(boolean start) {
        if (DBG) Log.d(TAG, "listen() - start: " + start);
        if (mService == null || mClientIf == 0) return;

        try {
            mService.clientListen(mClientIf, start);
        } catch (RemoteException e) {
            Log.e(TAG,"",e);
        }
    }

    /**
     * Sets the advertising data contained in the adv. response packet.
     *
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
     *
     * @param advData true to set adv. data, false to set scan response
     * @param includeName Inlucde the name in the adv. response
     * @param includeTxPower Include TX power value
     * @param minInterval Minimum desired scan interval (optional)
     * @param maxInterval Maximum desired scan interval (optional)
     * @param appearance The appearance flags for the device (optional)
     * @param manufacturerData Manufacturer specific data including company ID (optional)
     */
    /*package*/ void setAdvData(boolean advData, boolean includeName, boolean includeTxPower,
                           Integer minInterval, Integer maxInterval,
                           Integer appearance, Byte[] manufacturerData) {
        if (DBG) Log.d(TAG, "setAdvData()");
        if (mService == null || mClientIf == 0) return;

        byte[] data = new byte[0];
        if (manufacturerData != null) {
            data = new byte[manufacturerData.length];
            for(int i = 0; i != manufacturerData.length; ++i) {
                data[i] = manufacturerData[i];
            }
        }

        try {
            mService.setAdvData(mClientIf, !advData,
                includeName, includeTxPower,
                minInterval != null ? minInterval : 0,
                maxInterval != null ? maxInterval : 0,
                appearance != null ? appearance : 0, data);
        } catch (RemoteException e) {
            Log.e(TAG,"",e);
        }
    }

    /**
     * Disconnects an established connection, or cancels a connection attempt
     * currently in progress.
+4 −0
Original line number Diff line number Diff line
@@ -37,6 +37,10 @@ interface IBluetoothGatt {
    void unregisterClient(in int clientIf);
    void clientConnect(in int clientIf, in String address, in boolean isDirect);
    void clientDisconnect(in int clientIf, in String address);
    void clientListen(in int clientIf, in boolean start);
    void setAdvData(in int clientIf, in boolean setScanRsp, in boolean inclName,
                            in boolean inclTxPower, in int minInterval, in int maxInterval,
                            in int appearance, in byte[] manufacturerData);
    void refreshDevice(in int clientIf, in String address);
    void discoverServices(in int clientIf, in String address);
    void readCharacteristic(in int clientIf, in String address, in int srvcType,
+1 −0
Original line number Diff line number Diff line
@@ -63,4 +63,5 @@ interface IBluetoothGattCallback {
                             in int charInstId, in ParcelUuid charUuid,
                             in byte[] value);
    void onReadRemoteRssi(in String address, in int rssi, in int status);
    void onListen(in int status);
}