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

Commit 5ec00955 authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Gerrit Code Review
Browse files

Merge "LE low power scan feature"

parents b43991c7 ed6ec3b7
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ static jmethodID method_onBatchScanThresholdCrossed;

static jmethodID method_CreateonTrackAdvFoundLostObject;
static jmethodID method_onTrackAdvFoundLost;

static jmethodID method_onScanParamSetupCompleted;

/**
 * Server callback methods
@@ -591,6 +591,13 @@ void btgattc_track_adv_event_cb(btgatt_track_adv_info_t *p_adv_track_info)
    checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
}

void btgattc_scan_parameter_setup_completed_cb(int client_if, btgattc_error_t status)
{
    CHECK_CALLBACK_ENV
    sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onScanParamSetupCompleted, status, client_if);
    checkAndClearExceptionFromCallback(sCallbackEnv, __func__);
}

static const btgatt_client_callbacks_t sGattClientCallbacks = {
    btgattc_register_app_cb,
    btgattc_scan_result_cb,
@@ -623,7 +630,8 @@ static const btgatt_client_callbacks_t sGattClientCallbacks = {
    btgattc_batchscan_startstop_cb,
    btgattc_batchscan_reports_cb,
    btgattc_batchscan_threshold_cb,
    btgattc_track_adv_event_cb
    btgattc_track_adv_event_cb,
    btgattc_scan_parameter_setup_completed_cb
};


@@ -879,6 +887,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) {
    method_CreateonTrackAdvFoundLostObject = env->GetMethodID(clazz, "CreateonTrackAdvFoundLostObject", "(II[BI[BIIILjava/lang/String;IIII)Lcom/android/bluetooth/gatt/AdvtFilterOnFoundOnLostInfo;");
    method_onTrackAdvFoundLost = env->GetMethodID(clazz, "onTrackAdvFoundLost",
                                                         "(Lcom/android/bluetooth/gatt/AdvtFilterOnFoundOnLostInfo;)V");
    method_onScanParamSetupCompleted = env->GetMethodID(clazz, "onScanParamSetupCompleted", "(II)V");

    // Server callbacks

@@ -1313,10 +1322,11 @@ static void gattSetAdvDataNative(JNIEnv *env, jobject object, jint client_if,
}

static void gattSetScanParametersNative(JNIEnv* env, jobject object,
                                        jint scan_interval_unit, jint scan_window_unit)
                                        jint client_if, jint scan_interval_unit,
                                        jint scan_window_unit)
{
    if (!sGattIf) return;
    sGattIf->client->set_scan_parameters(scan_interval_unit, scan_window_unit);
    sGattIf->client->set_scan_parameters(client_if, scan_interval_unit, scan_window_unit);
}

static void gattClientScanFilterParamAddNative(JNIEnv* env, jobject object, jobject params)
@@ -1823,7 +1833,7 @@ static JNINativeMethod sScanMethods[] = {
    {"gattClientScanFilterDeleteNative", "(IIIIIJJJJLjava/lang/String;Ljava/lang/String;B[B[B)V", (void *) gattClientScanFilterDeleteNative},
    {"gattClientScanFilterClearNative", "(II)V", (void *) gattClientScanFilterClearNative},
    {"gattClientScanFilterEnableNative", "(IZ)V", (void *) gattClientScanFilterEnableNative},
    {"gattSetScanParametersNative", "(II)V", (void *) gattSetScanParametersNative},
    {"gattSetScanParametersNative", "(III)V", (void *) gattSetScanParametersNative},
};

// JNI functions defined in GattService class.
+12 −1
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ class AdapterProperties {
    private int mOffloadedScanResultStorageBytes;
    private int mVersSupported;
    private int mTotNumOfTrackableAdv;
    private boolean mIsExtendedScanSupported;
    private boolean mIsDebugLogSupported;
    private boolean mIsActivityAndEnergyReporting;

    // Lock for all getters and setters.
@@ -564,6 +566,10 @@ class AdapterProperties {
        mTotNumOfTrackableAdv = ((0xFF & ((int)val[11])) << 8)
                            + (0xFF & ((int)val[10]));

        // TBD - Logic to be modified by Google as needed here
        mIsExtendedScanSupported = ((0xFF & ((int)val[12])) != 0);
        mIsDebugLogSupported = ((0xFF & ((int)val[13])) != 0);

        Log.d(TAG, "BT_PROPERTY_LOCAL_LE_FEATURES: update from BT controller"
                + " mNumOfAdvertisementInstancesSupported = "
                + mNumOfAdvertisementInstancesSupported
@@ -579,7 +585,12 @@ class AdapterProperties {
                +" mVersSupported = "
                + mVersSupported
                + " mTotNumOfTrackableAdv = "
                + mTotNumOfTrackableAdv);
                + mTotNumOfTrackableAdv
                + " mIsExtendedScanSupported = "
                + mIsExtendedScanSupported
                + " mIsDebugLogSupported = "
                + mIsDebugLogSupported
                );
    }

    void onBluetoothReady() {
+10 −0
Original line number Diff line number Diff line
@@ -1179,6 +1179,16 @@ public class GattService extends ProfileService {
        }
    }

    void onScanParamSetupCompleted(int status, int clientIf) throws RemoteException {
        ClientMap.App app = mClientMap.getById(clientIf);
        if (app == null || app.callback == null) {
            Log.e(TAG, "Advertise app or callback is null");
            return;
        }
        // TBD - Logic to be modified by Google as needed here
        Log.d(TAG, "onScanParamSetupCompleted : " + status);
    }

    // callback from AdvertiseManager for advertise status dispatch.
    void onMultipleAdvertiseCallback(int clientIf, int status, boolean isStart,
            AdvertiseSettings settings) throws RemoteException {
+4 −2
Original line number Diff line number Diff line
@@ -416,7 +416,9 @@ public class ScanManager {
                    scanWindow = Utils.millsToUnit(scanWindow);
                    scanInterval = Utils.millsToUnit(scanInterval);
                    gattClientScanNative(false);
                    gattSetScanParametersNative(scanInterval, scanWindow);
                    logd("configureRegularScanParams - scanInterval = " + scanInterval +
                        "configureRegularScanParams - scanWindow = " + scanWindow);
                    gattSetScanParametersNative(client.clientIf, scanInterval, scanWindow);
                    gattClientScanNative(true);
                    mLastConfiguredScanSetting = curScanSetting;
                }
@@ -857,7 +859,7 @@ public class ScanManager {
        /************************** Regular scan related native methods **************************/
        private native void gattClientScanNative(boolean start);

        private native void gattSetScanParametersNative(int scan_interval,
        private native void gattSetScanParametersNative(int client_if, int scan_interval,
                int scan_window);

        /************************** Filter related native methods ********************************/