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

Commit 3acfa0db authored by Kiran Kelageri's avatar Kiran Kelageri Committed by Steve Kondik
Browse files

Bluetooth: Add SDK apis for Wipower and Peripheral feature

changes needed for Wipower and Periferal features.

CRs-fixed: 587811

Change-Id: Ibe73124daf78c79498fd1a6cbbcd75a88006c688
parent d9bc1b38
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ LOCAL_SRC_FILES += \
	core/java/android/app/backup/IFullBackupRestoreObserver.aidl \
	core/java/android/app/backup/IRestoreObserver.aidl \
	core/java/android/app/backup/IRestoreSession.aidl \
	core/java/android/wipower/IWipower.aidl \
	core/java/android/wipower/IWipowerManagerCallback.aidl \
	core/java/android/bluetooth/IBluetooth.aidl \
	core/java/android/bluetooth/IQBluetooth.aidl \
	core/java/android/bluetooth/IBluetoothA2dp.aidl \
+7 −0
Original line number Diff line number Diff line
@@ -45,6 +45,13 @@ import android.os.ParcelFileDescriptor;
 */
interface IQBluetooth
{
    int getLEAdvMode();
    boolean setLEAdvParams(int min_int, int max_int, String address, int ad_type);
    boolean setLEAdvMode(int mode);
    boolean setLEManuData(in byte[] manuData);
    boolean setLEServiceData(in byte[] serviceData);
    boolean setLEAdvMask(boolean bLocalName, boolean bServices, boolean bTxPower,boolean bManuData, boolean ServiceData);
    boolean setLEScanRespMask(boolean bLocalName, boolean bServices, boolean bTxPower,boolean bManuData );
    int     startLeScanEx(in BluetoothLEServiceUuid[] services, in IQBluetoothAdapterCallback callback);
    void    stopLeScanEx(in int token);
    boolean registerLeLppRssiMonitorClient(in String address, in IQBluetoothAdapterCallback client, in boolean add);
+164 −7
Original line number Diff line number Diff line
@@ -75,7 +75,33 @@ public final class QBluetoothAdapter {
    private static final boolean DBG = false;
    private static final boolean VDBG = false;

    private static final String BT_LE_EXTENDED_SCAN_PROP = "ro.qc.bluetooth.le.extendedscan";
    /** @hide */
    public static final int ADV_MODE_NONE = 24;
    /** @hide */
    public static final int ADV_IND_GENERAL_CONNECTABLE=25;
    /** @hide */
    public static final int ADV_IND_LIMITED_CONNECTABLE=26;
    /** @hide */
    public static final int ADV_DIR_CONNECTABLE=27;
   /**
     * Broadcast Action: The local QBluetooth adapter has changed the adv enable mode
     *which can be anything from adv_ind_limited, adv_ind_general, adv_directed or adv_none
     *<p> The adv type determines the way the remote devices can see and connect to the local adapter
     *<p> Always contains the extra field {@link #EXTRA_ADV_TYPE} containing
     *the type of adv currently active
     *<p> Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
     */
    /** @hide */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_ADV_ENABLE_CHANGED=
            "android.bluetooth.adapter.action.ADV_ENABLE_CHANGED";
    /**
     * Used as a String extra field in {@link #ACTION_LOCAL_NAME_CHANGED}
     * intents to request the local Bluetooth name.
     */
    /** @hide */
    public static final String EXTRA_ADV_ENABLE = "android.bluetooth.adapter.extra.ADV_ENABLE";
    private static final String BT_LE_EXTENDED_SCAN_PROP = "ro.q.bluetooth.le.extendedscan";
    private boolean mLeExtendedScanFlag = false;
    private static final int MAX_LE_EXTENDED_SCAN_FILTER_ENTRIES = 0x80;

@@ -131,7 +157,138 @@ public final class QBluetoothAdapter {
            mLeExtendedScanFlag = true;
        }
    }
    /**
    * gets the adv mode of LE adapter
    * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
    * permission
    * @return returns the LE adv mode
    /** @hide */
    public int getLEAdvMode() {
        if (mAdapter.getState() != BluetoothAdapter.STATE_ON) return ADV_MODE_NONE;
        try {
            synchronized(mManagerCallback) {
                if (mService != null && mQService!=null) return mQService.getLEAdvMode();
            }
        } catch (RemoteException e) {Log.e(TAG, "", e);}
        return ADV_MODE_NONE;
    }
    /**
    * sets the adv mode of LE adapter
    * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
    * permission
    * @return returns true if operation successful
    /** @hide */
    public boolean setLEAdvMode(int mode) {
        if (mAdapter.getState() != BluetoothAdapter.STATE_ON) return false;
        try {
            synchronized(mManagerCallback) {
                if (mService != null && mQService!=null)
                {
                    Log.v(TAG,"setLEAdvMode gng to call set LE adv mode Q");
                    return mQService.setLEAdvMode(mode);
                }
            }
        } catch (RemoteException e) {Log.e(TAG, "", e);}
        return false;
    }
    /**
    * sets the adv parameters of LE adapter
    * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
    * permission
    * @return returns true if operation successful
    /** @hide */
    public boolean setLEAdvParams(int min_int, int max_int, String address, int ad_type){
        if (mAdapter.getState() != BluetoothAdapter.STATE_ON) return false;
        Log.v(TAG, "QBluetooth adapter, setLEAdvParams calling service method min_int"
           + min_int +" max int:"+max_int + "address:" +address + " ad_type="+ ad_type);
        try {
            synchronized(mManagerCallback) {
                if (mService!=null && mQService != null) return mQService.setLEAdvParams(min_int, max_int, address, ad_type);
            }
        } catch (RemoteException e) {Log.e(TAG, "", e);}
        return false;
    }

    /**
    * sets the adv params of LE adapter
    * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
    * permission
    * @return returns true if operation successful
    /** @hide */
    public boolean setLEAdvParams(int min_int, int max_int){
        if (mAdapter.getState() != BluetoothAdapter.STATE_ON) return false;
        int ad_type=0;
        String address="00:00:00:00:00:00"; //null address
        Log.v(TAG, "QBluetooth adapter, setLEAdvParams min_int" + min_int +" max int:"+max_int + "address:" +address + " ad_type="+ ad_type);
        return setLEAdvParams(min_int, max_int, address, ad_type);
    }

    /**
    * sets the manufacturing data for advertisements of LE adapter
    * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
    * permission
    * @return returns true if operation successful
    /** @hide */
    public boolean setLEManuData(byte[] manuData){
        if (mAdapter.getState() != BluetoothAdapter.STATE_ON) return false;
        Log.v(TAG, "QBluetooth adapter, setLEManuData calling service method manu_data:" + manuData);
        try {
            synchronized(mManagerCallback) {
                if (mQService != null) return mQService.setLEManuData(manuData);
            }
        } catch (RemoteException e) {Log.e(TAG, "", e);}
        return false;
    }
    /**
    * sets the service data for advertisements of LE adapter
    * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
    * permission
    * @return returns true if operation successful
    /** @hide */
    public boolean setLEServiceData(byte[] serviceData){
        if (mAdapter.getState() != BluetoothAdapter.STATE_ON) return false;
        Log.v(TAG, "QBluetooth adapter, setLEServiceData calling service method setLEServiceData:" + serviceData);
        try {
            synchronized(mManagerCallback) {
                if (mQService != null) return mQService.setLEServiceData(serviceData);
            }
        } catch (RemoteException e) {Log.e(TAG, "", e);}
        return false;
    }

    /**
    * sets the adv mask for advertisements of LE adapter
    * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
    * permission
    * @return returns true if operation successful
    /** @hide */
    public boolean setLEAdvMask(boolean bLocalName, boolean bServices, boolean bTxPower,boolean bManuData, boolean ServiceData){
        if (mAdapter.getState() != BluetoothAdapter.STATE_ON) return false;
        Log.v(TAG, "QBluetooth adapter, setLEAdvMask calling service method blocalname:" + bLocalName + " bServices:" + bServices + " bTxPower:"+bTxPower + " bManuData:" + bManuData);
        try {
            synchronized(mManagerCallback) {
                if (mQService != null) return mQService.setLEAdvMask(bLocalName,bServices,bTxPower,bManuData, ServiceData);
            }
        } catch (RemoteException e) {Log.e(TAG, "", e);}
        return false;
    }

    /**
    * sets the adv mask for scan response of LE adapter
    * <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
    * permission
    * @return returns true if operation successful
    /** @hide */
    public boolean setLEScanRespMask(boolean bLocalName, boolean bServices, boolean bTxPower,boolean bManuData){
        if (mAdapter.getState() != BluetoothAdapter.STATE_ON) return false;
        Log.v(TAG, "QBluetooth adapter, setLEScanRespMask calling service method blocalname:" + bLocalName + " bServices:" + bServices + " bTxPower:"+bTxPower+ " bManuData:" + bManuData);
        try {
            synchronized(mManagerCallback) {
                if (mQService != null) return mQService.setLEScanRespMask(bLocalName,bServices,bTxPower,bManuData);
            }
        } catch (RemoteException e) {Log.e(TAG, "", e);}
        return false;
    }
    /**
     * Starts a scan for Bluetooth LE devices, looking for devices that
     * advertise given services.It is the most optimal way to filter scan
@@ -156,7 +313,7 @@ public final class QBluetoothAdapter {
     *         false,if parameter is bad or chipset doesn't support filtering scan results in controller
     */
    public boolean startLeScanEx(BluetoothLEServiceUuid[] serviceUuids, BluetoothAdapter.LeScanCallback callback) {
        if (VDBG) Log.d(TAG, "startLeScanEx(): " + serviceUuids);
        if (VDBG) Log.v(TAG, "startLeScanEx(): " + serviceUuids);
        if (!mLeExtendedScanFlag) {
            if (DBG) Log.e(TAG, "startLeScanEx: function is diabled since chipset doesn't support filtering" +
                                 "scan results in controller, use startLeScan instead");
@@ -179,9 +336,9 @@ public final class QBluetoothAdapter {

        synchronized(mScanLock) {
            if (mLeScanClient != null) {
                if (VDBG) Log.e(TAG, "LE Scan in progress");
                if (VDBG) Log.v(TAG, "LE Scan in progress");
                if (mLeScanClient.first == callback)
                    if (DBG) Log.e(TAG, "duplicate scan request");
                    if (DBG) Log.v(TAG, "duplicate scan request");
                return false;
            }

@@ -581,11 +738,11 @@ public final class QBluetoothAdapter {

    final private IQBluetoothManagerCallback mManagerCallback =
        new IQBluetoothManagerCallback.Stub() {
            public void onQBluetoothServiceUp(IQBluetooth qcbluetoothService) {
                if (VDBG) Log.i(TAG, "on QBluetoothServiceUp: " + qcbluetoothService);
            public void onQBluetoothServiceUp(IQBluetooth qbluetoothService) {
                if (VDBG) Log.i(TAG, "on QBluetoothServiceUp: " + qbluetoothService);
                synchronized (mManagerCallback) {
                    //initialize the global params again
                    mQService = qcbluetoothService;
                    mQService = qbluetoothService;
                    Log.i(TAG,"onQBluetoothServiceUp: Adapter ON: mService: "+ mService + " mQService: " + mQService+ " ManagerService:" + mManagerService);
                }
            }
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of The Linux Foundation nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package android.wipower;


import android.wipower.IWipowerManagerCallback;
import android.os.ParcelUuid;
import android.os.ParcelFileDescriptor;

/**
 * System private API for talking with the WiPower Manger.
 *
 * {@hide}
 */
interface IWipower
{
    int getState();
    boolean startCharging();
    boolean stopCharging();

    boolean setCurrentLimit(in byte value);
    byte getCurrentLimit();

    boolean enableAlert(boolean enable);
    boolean enableData(boolean enable);

    void registerCallback(in IWipowerManagerCallback callback);
    void unregisterCallback(in IWipowerManagerCallback callback);

}
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of The Linux Foundation nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package android.wipower;

/**
 * Application level callback for Wipower manager APIs.
 *
 * {@hide}
 */
interface IWipowerManagerCallback
{
    void onWipowerStateChange(int state);

    void onWipowerAlert(byte alert);

    void onWipowerData(in byte[] value);
}
Loading