Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature DiscoverService with clearCache #453

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ apply from: 'dependencies.gradle'
apply from: 'checkstyle.gradle'

buildscript {
ext.kotlinVersion = '1.3.31'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.21.0'
classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:2.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41"
}
}

Expand Down
24 changes: 0 additions & 24 deletions dagger-compiler-shadow/build.gradle

This file was deleted.

29 changes: 0 additions & 29 deletions dagger-library-shadow/build.gradle

This file was deleted.

4 changes: 0 additions & 4 deletions dagger-library-shadow/gradle.properties

This file was deleted.

9 changes: 3 additions & 6 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
ext {
rxJavaVersion = '2.2.8'
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
shadowPluginVersion = '2.0.2'
daggerVersion = '2.15'
libs = [
/* Library-only dependencies */
rxjava : "io.reactivex.rxjava2:rxjava:$rxJavaVersion",
rxjava : "io.reactivex.rxjava2:rxjava:2.2.8",
rxandroid : 'io.reactivex.rxjava2:rxandroid:2.1.1',
rxrelay : 'com.jakewharton.rxrelay2:rxrelay:2.1.0',
junit : 'junit:junit:4.12',
Expand All @@ -15,8 +12,8 @@ ext {
'cglib:cglib-nodep:3.2.12',
'org.objenesis:objenesis:2.6'],
electricspock : 'com.github.hkhc:electricspock:0.9',
dagger : "com.google.dagger:dagger:$daggerVersion",
dagger_compiler : "com.google.dagger:dagger-compiler:$daggerVersion",
dagger : "com.google.dagger:dagger:2.22.1",
dagger_compiler : "com.google.dagger:dagger-compiler:2.22.1",
/* Shared library-sample apps dependencies */
annotations : "androidx.annotation:annotation:1.0.2",
robolectric : 'org.robolectric:robolectric:3.8',
Expand Down
4 changes: 0 additions & 4 deletions gradle/shadow.gradle

This file was deleted.

4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Feb 27 15:06:12 CET 2019
#Mon Aug 12 10:50:50 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public Single<RxBleDeviceServices> discoverServices(long timeout, @NonNull TimeU
return Single.just(rxBleDeviceServices);
}

@Override
public Single<RxBleDeviceServices> discoverServices(long timeout, @NonNull TimeUnit timeUnit, Boolean clearCache) {
return Single.just(rxBleDeviceServices);
}

@Override
public Single<BluetoothGattCharacteristic> getCharacteristic(@NonNull final UUID characteristicUuid) {
return discoverServices()
Expand Down
6 changes: 3 additions & 3 deletions rxandroidble/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ dependencies {
api rootProject.ext.libs.rxjava
api rootProject.ext.libs.annotations
implementation rootProject.ext.libs.rxrelay
implementation project(path: ':dagger-library-shadow', transitive: false, configuration: 'shadow')
annotationProcessor project(path: ':dagger-compiler-shadow', transitive: false, configuration: 'shadow')
implementation rootProject.ext.libs.dagger
annotationProcessor rootProject.ext.libs.dagger_compiler

// Test dependencies
testImplementation project(path: ':dagger-library-shadow', transitive: false, configuration: 'shadow')
testImplementation rootProject.ext.libs.dagger
testImplementation rootProject.ext.libs.junit
testImplementation rootProject.ext.libs.groovy
testImplementation rootProject.ext.libs.spock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import bleshadow.dagger.Binds;
import bleshadow.dagger.BindsInstance;
import bleshadow.dagger.Component;
import bleshadow.dagger.Module;
import bleshadow.dagger.Provides;
import bleshadow.javax.inject.Named;
import bleshadow.javax.inject.Provider;
import dagger.Binds;
import dagger.BindsInstance;
import dagger.Component;
import dagger.Module;
import dagger.Provides;
import javax.inject.Named;
import javax.inject.Provider;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Function;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import bleshadow.javax.inject.Scope;
import javax.inject.Scope;

@Scope
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.content.IntentFilter;
import androidx.annotation.NonNull;

import bleshadow.javax.inject.Inject;
import javax.inject.Inject;
import com.polidea.rxandroidble2.internal.RxBleLog;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import java.util.UUID;
import java.util.concurrent.Callable;

import bleshadow.dagger.Lazy;
import bleshadow.javax.inject.Inject;
import bleshadow.javax.inject.Named;
import dagger.Lazy;
import javax.inject.Inject;
import javax.inject.Named;
import io.reactivex.Maybe;
import io.reactivex.MaybeSource;
import io.reactivex.Observable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,28 @@ interface WriteOperationAckStrategy extends ObservableTransformer<Boolean, Boole
*/
Single<RxBleDeviceServices> discoverServices(@IntRange(from = 1) long timeout, @NonNull TimeUnit timeUnit);

/**
* Performs GATT service discovery and emits discovered results. After service discovery you can walk through
* {@link android.bluetooth.BluetoothGattService}s and {@link BluetoothGattCharacteristic}s.
* <p>
* Result of the discovery is cached internally so consecutive calls won't trigger BLE operation and can be
* considered relatively lightweight.
*
* Timeouts after specified amount of time.
*
* The cache can be cleared to perform a new Gatt Discover and maybe find a service previously hidden
*
* @param timeout multiplier of TimeUnit after which the discovery will timeout in case of no return values
* @param timeUnit TimeUnit for the timeout
* @param clearCache Flag to ask the cache clearing (Warning, this functionnality can alter the good working of your app
* You should have strong knowledge of how it works)
* @return Observable emitting result a GATT service discovery.
* @throws BleGattCannotStartException with {@link BleGattOperationType#SERVICE_DISCOVERY} type, when it wasn't possible to start
* the discovery for internal reasons.
* @throws BleGattException in case of GATT operation error with {@link BleGattOperationType#SERVICE_DISCOVERY} type.
*/
Single<RxBleDeviceServices> discoverServices(@IntRange(from = 1) long timeout, @NonNull TimeUnit timeUnit, Boolean clearCache);

/**
* @see #setupNotification(UUID, NotificationSetupMode) with default setup mode.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import java.util.UUID;

import bleshadow.javax.inject.Inject;
import bleshadow.javax.inject.Named;
import javax.inject.Inject;
import javax.inject.Named;
import io.reactivex.Observable;
import io.reactivex.Observer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import com.polidea.rxandroidble2.RxBleDevice;

import bleshadow.dagger.BindsInstance;
import bleshadow.dagger.Subcomponent;
import bleshadow.javax.inject.Named;
import dagger.BindsInstance;
import dagger.Subcomponent;
import javax.inject.Named;

@DeviceScope
@Subcomponent(modules = {DeviceModule.class})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

import java.util.concurrent.TimeUnit;

import bleshadow.dagger.Binds;
import bleshadow.dagger.Module;
import bleshadow.dagger.Provides;
import bleshadow.javax.inject.Named;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import javax.inject.Named;
import io.reactivex.Scheduler;

@Module(subcomponents = ConnectionComponent.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import bleshadow.javax.inject.Scope;
import javax.inject.Scope;

@Scope
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;

import bleshadow.javax.inject.Inject;
import javax.inject.Inject;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.functions.Action;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import java.util.Map;

import bleshadow.javax.inject.Inject;
import bleshadow.javax.inject.Provider;
import javax.inject.Inject;
import javax.inject.Provider;

@ClientScope
public class RxBleDeviceProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Map;
import java.util.Set;

import bleshadow.javax.inject.Inject;
import javax.inject.Inject;

@ClientScope
public class DeviceComponentCache implements Map<String, DeviceComponent> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import java.util.concurrent.atomic.AtomicReference;

import bleshadow.javax.inject.Inject;
import javax.inject.Inject;

@ConnectionScope
public class BluetoothGattProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.polidea.rxandroidble2.RxBleConnection;
import com.polidea.rxandroidble2.Timeout;
import com.polidea.rxandroidble2.internal.operations.ConnectOperation;
import bleshadow.dagger.BindsInstance;
import bleshadow.dagger.Subcomponent;
import bleshadow.javax.inject.Named;
import dagger.BindsInstance;
import dagger.Subcomponent;
import javax.inject.Named;
import java.util.Set;

@ConnectionScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import com.polidea.rxandroidble2.internal.serialization.ConnectionOperationQueueImpl;
import com.polidea.rxandroidble2.internal.util.CharacteristicPropertiesParser;

import bleshadow.dagger.Binds;
import bleshadow.dagger.Module;
import bleshadow.dagger.Provides;
import bleshadow.dagger.multibindings.IntoSet;
import bleshadow.javax.inject.Named;
import bleshadow.javax.inject.Provider;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.multibindings.IntoSet;
import javax.inject.Named;
import javax.inject.Provider;
import io.reactivex.Scheduler;

import static com.polidea.rxandroidble2.internal.connection.ConnectionComponent.NamedBooleans.SUPPRESS_OPERATION_CHECKS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import bleshadow.javax.inject.Scope;
import javax.inject.Scope;

@Scope
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import java.util.Set;
import java.util.concurrent.Callable;

import bleshadow.javax.inject.Inject;
import bleshadow.javax.inject.Named;
import javax.inject.Inject;
import javax.inject.Named;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.Scheduler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.polidea.rxandroidble2.internal.operations.OperationsProvider;
import com.polidea.rxandroidble2.internal.serialization.ConnectionOperationQueue;

import bleshadow.javax.inject.Inject;
import javax.inject.Inject;
import io.reactivex.Completable;

@ConnectionScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.polidea.rxandroidble2.internal.operations.DisconnectOperation;
import com.polidea.rxandroidble2.internal.serialization.ClientOperationQueue;

import bleshadow.javax.inject.Inject;
import javax.inject.Inject;

import io.reactivex.internal.functions.Functions;

Expand Down
Loading