diff --git a/CHANGELOG.md b/CHANGELOG.md index eb63a3ed..35c030a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ +# TAG v2.0.0 - Test + +- added force flag to force deletion of inet box bonding +- added tests +- added permission checks + # TAG v1.1.127 - Test +# TAG v1.1.128 - Test - check if either the connected device address matches to the bonding mac address or the device name contains "iNet Box" to remove the bonding diff --git a/example/pubspec.lock b/example/pubspec.lock index 5d01f488..c9c79c4a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -157,10 +157,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" convert: dependency: transitive description: @@ -330,6 +330,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -350,26 +374,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.12.0" mime: dependency: transitive description: @@ -398,10 +422,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" pedantic: dependency: transitive description: @@ -468,11 +492,9 @@ packages: reactive_ble_platform_interface: dependency: transitive description: - path: "packages/reactive_ble_platform_interface" - ref: "v1.1.122" - resolved-ref: a4841293194e9f77843c5479d1622f6c66438d1e - url: "https://github.com/ben91187/flutter_reactive_ble.git" - source: git + path: "../packages/reactive_ble_platform_interface" + relative: true + source: path version: "5.0.2" shelf: dependency: transitive @@ -515,18 +537,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" stream_transform: dependency: transitive description: @@ -555,10 +577,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.7.0" timing: dependency: transitive description: @@ -583,22 +605,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - watcher: + vm_service: dependency: transitive description: - name: watcher - sha256: "68173f2fa67d241323a4123be7ed4e43424c54befa5505d71c8ad4b7baf8f71d" + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "1.0.0" - web: + version: "14.2.1" + watcher: dependency: transitive description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + name: watcher + sha256: "68173f2fa67d241323a4123be7ed4e43424c54befa5505d71c8ad4b7baf8f71d" url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "1.0.0" web_socket_channel: dependency: transitive description: @@ -616,5 +638,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=2.0.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/packages/flutter_reactive_ble/pubspec.lock b/packages/flutter_reactive_ble/pubspec.lock index a00ed3f8..d18a4959 100644 --- a/packages/flutter_reactive_ble/pubspec.lock +++ b/packages/flutter_reactive_ble/pubspec.lock @@ -133,18 +133,18 @@ packages: dependency: transitive description: name: code_builder - sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe" + sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.10.0" collection: dependency: "direct main" description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" convert: dependency: transitive description: @@ -291,6 +291,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -311,26 +335,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: "direct main" description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.12.0" mime: dependency: transitive description: @@ -343,10 +367,10 @@ packages: dependency: "direct dev" description: name: mockito - sha256: "8b46d7eb40abdda92d62edd01546051f0c27365e65608c284de336dccfef88cc" + sha256: "6841eed20a7befac0ce07df8116c8b8233ed1f4486a7647c7fc5a02ae6163917" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "5.4.4" package_config: dependency: transitive description: @@ -359,10 +383,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" plugin_platform_interface: dependency: transitive description: @@ -406,20 +430,16 @@ packages: reactive_ble_mobile: dependency: "direct main" description: - path: "packages/reactive_ble_mobile" - ref: "v1.1.122" - resolved-ref: a4841293194e9f77843c5479d1622f6c66438d1e - url: "https://github.com/ben91187/flutter_reactive_ble.git" - source: git + path: "../reactive_ble_mobile" + relative: true + source: path version: "5.0.2" reactive_ble_platform_interface: dependency: "direct main" description: - path: "packages/reactive_ble_platform_interface" - ref: "v1.1.122" - resolved-ref: a4841293194e9f77843c5479d1622f6c66438d1e - url: "https://github.com/ben91187/flutter_reactive_ble.git" - source: git + path: "../reactive_ble_platform_interface" + relative: true + source: path version: "5.0.2" shelf: dependency: transitive @@ -462,18 +482,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" stream_transform: dependency: transitive description: @@ -502,10 +522,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.7.0" timing: dependency: transitive description: @@ -530,22 +550,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - watcher: + vm_service: dependency: transitive description: - name: watcher - sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "1.0.2" - web: + version: "14.2.1" + watcher: dependency: transitive description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + name: watcher + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "1.0.2" web_socket_channel: dependency: transitive description: @@ -563,5 +583,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=2.0.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/packages/flutter_reactive_ble/pubspec.yaml b/packages/flutter_reactive_ble/pubspec.yaml index 676c6d51..9a781b87 100644 --- a/packages/flutter_reactive_ble/pubspec.yaml +++ b/packages/flutter_reactive_ble/pubspec.yaml @@ -21,16 +21,20 @@ dependencies: sdk: flutter functional_data: ^1.0.0 meta: ^1.3.0 +# reactive_ble_mobile: +# path: ../reactive_ble_mobile +# reactive_ble_platform_interface: +# path: ../reactive_ble_platform_interface reactive_ble_mobile: git: url: https://github.com/ben91187/flutter_reactive_ble.git path: packages/reactive_ble_mobile - ref: v1.1.127 + ref: v2.0.0 reactive_ble_platform_interface: git: url: https://github.com/ben91187/flutter_reactive_ble.git path: packages/reactive_ble_platform_interface - ref: v1.1.127 + ref: v2.0.0 dev_dependencies: build_runner: ^2.1.2 flutter_lints: ^1.0.4 diff --git a/packages/reactive_ble_mobile/android/build.gradle b/packages/reactive_ble_mobile/android/build.gradle index a8ff8961..f2894e64 100644 --- a/packages/reactive_ble_mobile/android/build.gradle +++ b/packages/reactive_ble_mobile/android/build.gradle @@ -104,6 +104,7 @@ dependencies { implementation 'com.google.protobuf:protobuf-javalite:3.18.1' implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' + implementation 'androidx.core:core:1.13.1' testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.0" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.0" diff --git a/packages/reactive_ble_mobile/android/gradle/wrapper/gradle-wrapper.jar b/packages/reactive_ble_mobile/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..7454180f Binary files /dev/null and b/packages/reactive_ble_mobile/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/packages/reactive_ble_mobile/android/gradlew b/packages/reactive_ble_mobile/android/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/packages/reactive_ble_mobile/android/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/packages/reactive_ble_mobile/android/gradlew.bat b/packages/reactive_ble_mobile/android/gradlew.bat new file mode 100644 index 00000000..107acd32 --- /dev/null +++ b/packages/reactive_ble_mobile/android/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/PluginController.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/PluginController.kt index 8e0e824e..e08c1218 100644 --- a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/PluginController.kt +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/PluginController.kt @@ -321,7 +321,13 @@ class PluginController { private fun removeInetBoxBonding(call: MethodCall, result: Result) { val macAddressInfo = pb.BtMacAddressInfo.parseFrom(call.arguments as ByteArray) - result.success(bleClient.removeInetBoxBonding(macAddressInfo.deviceId, macAddressInfo.forceDelete)) + result.success( + bleClient.removeInetBoxBonding( + macAddressInfo.deviceId, + macAddressInfo.forceDelete, + null + ) + ) } private fun addGattCharacteristic(call: MethodCall, result: Result) { diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleClient.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleClient.kt index 3de2e1fb..041afe2c 100644 --- a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleClient.kt +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/BleClient.kt @@ -1,5 +1,8 @@ package com.signify.hue.flutterreactiveble.ble +import android.bluetooth.BluetoothAdapter +import android.bluetooth.BluetoothManager +import android.content.Context import android.os.ParcelUuid import com.polidea.rxandroidble2.RxBleDeviceServices import com.signify.hue.flutterreactiveble.model.ScanMode @@ -70,7 +73,7 @@ interface BleClient { fun startGattServer() fun stopGattServer() fun checkIfOldInetBoxBondingExists(deviceId: String): Boolean - fun removeInetBoxBonding(deviceId: String, forceDelete: Boolean): Boolean + fun removeInetBoxBonding(deviceId: String, forceDelete: Boolean, context: Context?): Boolean fun writeLocalCharacteristic( deviceId: String, characteristic: UUID, diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClient.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClient.kt index e50e6047..f433ea3d 100644 --- a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClient.kt +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClient.kt @@ -2,7 +2,7 @@ package com.signify.hue.flutterreactiveble.ble import android.Manifest import android.annotation.SuppressLint -import android.app.ActivityManager +import android.annotation.TargetApi import android.bluetooth.BluetoothDevice.BOND_BONDING import android.bluetooth.BluetoothGattCharacteristic import android.content.Context @@ -41,9 +41,11 @@ import android.bluetooth.BluetoothAdapter import android.bluetooth.BluetoothManager import android.bluetooth.le.* import android.bluetooth.* +import android.bluetooth.BluetoothDevice import android.content.pm.PackageManager import android.util.Log import androidx.core.app.ActivityCompat +import com.signify.hue.flutterreactiveble.utils.BuildConfig import kotlin.random.Random private const val tag: String = "ReactiveBleClient" @@ -253,7 +255,7 @@ open class ReactiveBleClient(private val context: Context) : BleClient { the bonding with the peripheral. By retrying the operation once we deviate between this flaky one time error and real auth failed cases */ - .retry(1) { Build.VERSION.SDK_INT < Build.VERSION_CODES.O } + .retry(1) { BuildConfig().getVersionSDKInt() < Build.VERSION_CODES.O } .map { value -> CharOperationSuccessful(deviceId, value.asList()) } @@ -736,7 +738,7 @@ open class ReactiveBleClient(private val context: Context) : BleClient { null ); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (BuildConfig().getVersionSDKInt() >= Build.VERSION_CODES.M) { mBluetoothGatt = device?.connectGatt( context, false, @@ -930,9 +932,9 @@ open class ReactiveBleClient(private val context: Context) : BleClient { return } while (!mBluetoothGattServer!!.removeService(service)) { - Log.d(tag, "gatt service ${service} not removed") + Log.d(tag, "gatt service $service not removed") } - Log.d(tag, "gatt service ${service} removed") + Log.d(tag, "gatt service $service removed") } override fun addGattService() { @@ -945,21 +947,73 @@ open class ReactiveBleClient(private val context: Context) : BleClient { // TODO Move from addExampleGattService to addGattCharacteristic } + /** + * Checks if a bonded device is of type classic bonding. This can be determined by the device type. + * The device types value can be [BluetoothDevice.DEVICE_TYPE_CLASSIC] or [BluetoothDevice.DEVICE_TYPE_DUAL] + */ + @TargetApi(34) + fun isClassicBonding(device: BluetoothDevice, ctx: Context?, buildCnfg: BuildConfig?): Boolean { + try { + val config = buildCnfg ?: BuildConfig() + val btPermission = when (config.getVersionSDKInt()) { + in 1..Build.VERSION_CODES.R -> Manifest.permission.BLUETOOTH + else -> Manifest.permission.BLUETOOTH_CONNECT + } + if (ActivityCompat.checkSelfPermission( + ctx ?: context, + btPermission + ) != PackageManager.PERMISSION_GRANTED + ) { + Log.i(tag, "Bt permission denied"); + return false + } + return (device.getType() == BluetoothDevice.DEVICE_TYPE_CLASSIC) || (device.getType() == BluetoothDevice.DEVICE_TYPE_DUAL) + } catch (e: Exception) { + Log.i(tag, "An error occured while checking the iNet System bonding type") + Log.i(tag, e.toString()) + return false; + } + } + /** * Checks if old bonding exists, and if, allows showing the delete iNetBox Bondings pop up. * */ + @TargetApi(34) override fun checkIfOldInetBoxBondingExists(deviceId: String): Boolean { try { val bluetoothManager: BluetoothManager = ctx.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager val bluetoothAdapter: BluetoothAdapter = bluetoothManager.adapter - Log.i(tag, "check bonding for device id: ${deviceId}"); + Log.i(tag, "check bonding for device id: $deviceId"); - val bondedDevices: Set = bluetoothAdapter.getBondedDevices() - if (searchForBondedDevice(deviceId, bondedDevices) != null) { - Log.i(tag, "found iNet Box bonding") + val btPermission = + when (com.signify.hue.flutterreactiveble.utils.BuildConfig().getVersionSDKInt()) { + in 1..Build.VERSION_CODES.R -> Manifest.permission.BLUETOOTH + else -> Manifest.permission.BLUETOOTH_CONNECT + } + /*if (BuildConfig().checkSelfPermission( + context, + btPermission + ) != PackageManager.PERMISSION_GRANTED + ) { + Log.i(tag, "Bluetooth permission not granted!"); + return false + }*/ + if (ActivityCompat.checkSelfPermission( + context, + btPermission + ) != PackageManager.PERMISSION_GRANTED + ) { + Log.i(tag, "Bluetooth permission not granted!"); + return false + } + + val bondedDevices: Set = bluetoothAdapter.getBondedDevices() + val bondedDevice = searchForBondedDevice(deviceId, bondedDevices) + if (bondedDevice != null && isClassicBonding(bondedDevice, null, null)) { + Log.i(tag, "found old iNet Box bonding") return true; } Log.i(tag, "found no iNet Box bonding") @@ -977,32 +1031,37 @@ open class ReactiveBleClient(private val context: Context) : BleClient { * If the bonded iNetBox is from type 0x00000002 - DEVICE_TYPE_LE this iNetBox was * bonded via the new flutter app. * https://developer.android.com/reference/android/bluetooth/BluetoothDevice#DEVICE_TYPE_DUAL + * If [forceDelete] is set, the bonded device will be removed regardless of the device type. * */ - override fun removeInetBoxBonding( deviceId: String, forceDelete: Boolean, + context: Context?, ): Boolean { try { - val bluetoothManager: BluetoothManager = - context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager - val bluetoothAdapter: BluetoothAdapter = bluetoothManager.adapter + val ctx = context ?: this.context + val btManager: BluetoothManager = + ctx.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager + val bluetoothAdapter: BluetoothAdapter = btManager.adapter + val btPermission = when (BuildConfig().getVersionSDKInt()) { + in 1..Build.VERSION_CODES.R -> Manifest.permission.BLUETOOTH + else -> Manifest.permission.BLUETOOTH_CONNECT + } if (ActivityCompat.checkSelfPermission( - context, - Manifest.permission.BLUETOOTH_CONNECT + ctx, + btPermission ) != PackageManager.PERMISSION_GRANTED ) { - Log.i(tag, "Bluetooth permission not granted!") - Log.e(tag, "Bluetooth permission not granted!") + Log.i(tag, "Bt permission denied"); return false } - + Log.i(tag, "Bluetooth permission not granted!") val bondedDevices: Set = bluetoothAdapter.getBondedDevices() - Log.i(tag, "start remove bonding for device id: ${deviceId}"); + Log.i(tag, "start remove bonding for device id: $deviceId"); val foundDevice: BluetoothDevice? = searchForBondedDevice(deviceId, bondedDevices) @@ -1011,8 +1070,7 @@ open class ReactiveBleClient(private val context: Context) : BleClient { return false; } - val isBtClassicBonding: Boolean = - (foundDevice.getType() == 0x00000001) || (foundDevice.getType() == 0x00000003); + val isBtClassicBonding: Boolean = isClassicBonding(foundDevice, null, null) Log.i(tag, "is classic bonding: $isBtClassicBonding") Log.i(tag, "forceDelete: $forceDelete") @@ -1032,6 +1090,7 @@ open class ReactiveBleClient(private val context: Context) : BleClient { } } + /** * [deviceId] is empty, in case of an existing bonding with the iNet Box, paired through the * Truma app. Thus, one have to check if the deviceName contains the string "iNet Box" as the @@ -1045,7 +1104,7 @@ open class ReactiveBleClient(private val context: Context) : BleClient { * services after a firmware migration. * */ @SuppressLint("MissingPermission") - public fun searchForBondedDevice( + fun searchForBondedDevice( deviceId: String, bondedDevices: Set ): BluetoothDevice? { @@ -1065,12 +1124,12 @@ open class ReactiveBleClient(private val context: Context) : BleClient { Log.i(tag, "found bonded iNet Box"); return device; } - Log.i(tag, "No existing bonding found!"); } + Log.i(tag, "No existing bonding found!"); return null; } catch (e: Exception) { Log.e(tag, "Exception while iterating over bondings"); - Log.e(tag, "Exception: ${e.toString()}"); + Log.e(tag, "Exception: $e"); return null; } } @@ -1083,8 +1142,8 @@ open class ReactiveBleClient(private val context: Context) : BleClient { // TODO write to local characteristic and notify val servicesList: List = mBluetoothGattServer!!.getServices() - for (i in 0 until servicesList.size) { - val bluetoothGattService: BluetoothGattService = servicesList[i] + for (element in servicesList) { + val bluetoothGattService: BluetoothGattService = element val bluetoothGattCharacteristicList: List = bluetoothGattService.getCharacteristics() @@ -1145,7 +1204,7 @@ open class ReactiveBleClient(private val context: Context) : BleClient { the bonding with the peripheral. By retrying the operation once we deviate between this flaky one time error and real auth failed cases */ - .retry(1) { Build.VERSION.SDK_INT < Build.VERSION_CODES.O } + .retry(1) { BuildConfig().getVersionSDKInt() < Build.VERSION_CODES.O } .map { value -> CharOperationSuccessful(deviceId, value.asList()) } diff --git a/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/utils/BuildConfig.kt b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/utils/BuildConfig.kt new file mode 100644 index 00000000..2d42c2ed --- /dev/null +++ b/packages/reactive_ble_mobile/android/src/main/kotlin/com/signify/hue/flutterreactiveble/utils/BuildConfig.kt @@ -0,0 +1,28 @@ +package com.signify.hue.flutterreactiveble.utils + +import android.Manifest +import android.content.Context +import android.content.pm.PackageManager +import android.os.Build +import android.os.Process +import android.text.TextUtils +import androidx.core.app.NotificationManagerCompat +import androidx.core.util.ObjectsCompat + +class BuildConfig { + fun getVersionSDKInt(): Int { + return Build.VERSION.SDK_INT + } + + fun checkSelfPermission(context: Context, permission: String): Int { + ObjectsCompat.requireNonNull(permission, "permission must be non-null") + if (Build.VERSION.SDK_INT < 33 + && TextUtils.equals("android.permission.POST_NOTIFICATIONS", permission) + ) { + return if (NotificationManagerCompat.from(context).areNotificationsEnabled() + ) PackageManager.PERMISSION_GRANTED + else PackageManager.PERMISSION_DENIED + } + return context.checkPermission(permission, Process.myPid(), Process.myUid()) + } +} \ No newline at end of file diff --git a/packages/reactive_ble_mobile/android/src/test/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClientTest.kt b/packages/reactive_ble_mobile/android/src/test/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClientTest.kt index 4164765c..149c0048 100644 --- a/packages/reactive_ble_mobile/android/src/test/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClientTest.kt +++ b/packages/reactive_ble_mobile/android/src/test/kotlin/com/signify/hue/flutterreactiveble/ble/ReactiveBleClientTest.kt @@ -8,16 +8,22 @@ import android.bluetooth.BluetoothDevice.BOND_BONDED import android.bluetooth.BluetoothManager import android.content.Context import android.content.pm.PackageManager +import android.os.Build +import android.os.Process +import android.text.TextUtils import android.util.Log import androidx.core.app.ActivityCompat +import androidx.core.app.NotificationManagerCompat import com.google.common.truth.Truth.assertThat import com.polidea.rxandroidble2.RxBleClient import com.polidea.rxandroidble2.RxBleConnection import com.polidea.rxandroidble2.RxBleDevice import com.polidea.rxandroidble2.RxBleDeviceServices +import com.signify.hue.flutterreactiveble.BuildConfig as FBuildConfig +import com.signify.hue.flutterreactiveble.utils.Duration as FDuration import com.signify.hue.flutterreactiveble.ble.extensions.writeCharWithResponse import com.signify.hue.flutterreactiveble.ble.extensions.writeCharWithoutResponse -import com.signify.hue.flutterreactiveble.utils.Duration +import com.signify.hue.flutterreactiveble.utils.BuildConfig import io.mockk.MockKAnnotations import io.mockk.every import io.mockk.impl.annotations.MockK @@ -30,11 +36,14 @@ import io.reactivex.Single import io.reactivex.android.plugins.RxAndroidPlugins import io.reactivex.schedulers.TestScheduler import io.reactivex.subjects.BehaviorSubject +import junit.framework.Assert.assertTrue +import junit.framework.TestCase.assertFalse import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test +import java.time.Duration import java.util.UUID import java.util.concurrent.TimeUnit @@ -49,7 +58,7 @@ private class BleClientForTesting( activeConnections = mutableMapOf() } - override fun createDeviceConnector(device: RxBleDevice, timeout: Duration): DeviceConnector = + override fun createDeviceConnector(device: RxBleDevice, timeout: FDuration): DeviceConnector = deviceConnector } @@ -78,7 +87,7 @@ class ReactiveBleClientTest { private lateinit var sut: BleClientForTesting - private val testTimeout = Duration(100L, TimeUnit.MILLISECONDS) + private val testTimeout = FDuration(100L, TimeUnit.MILLISECONDS) private var testScheduler: TestScheduler? = null @@ -541,4 +550,222 @@ class ReactiveBleClientTest { assertThat(result).isEqualTo(device2) } } + + @Nested + @DisplayName("Check for classic bonding") + inner class CheckForClassicBonding { + + @BeforeEach + fun setup() { + mockkStatic(Log::class) + mockkStatic(TextUtils::class) + mockkStatic(NotificationManagerCompat::class) + mockkStatic(ActivityCompat::class) + mockkStatic(Process::class) + every { Log.v(any(), any()) } returns 0 + every { Log.d(any(), any()) } returns 0 + every { Log.i(any(), any()) } returns 0 + every { Log.e(any(), any()) } returns 0 + every { bleDevice.bluetoothDevice }.returns(bluetoothDevice) + + } + + @Test + fun `test permission denied returns false`() { + // Mock permission check to simulate denied permission + val mockContext = mockk() + val mBtManager = mockk() + val mBtAdapter = mockk() + val buildConfig = mockk() + + mockkStatic(Log::class) + mockkStatic(TextUtils::class) + mockkStatic(NotificationManagerCompat::class) + mockkStatic(ActivityCompat::class) + mockkStatic(Process::class) + + every { buildConfig.getVersionSDKInt() } returns 29 + + val btPermission = when (buildConfig.getVersionSDKInt()) { + in 1..Build.VERSION_CODES.R -> Manifest.permission.BLUETOOTH + else -> Manifest.permission.BLUETOOTH_CONNECT + } + + every { Process.myPid() } returns 1234 + every { Process.myUid() } returns 5678 + every { context.getSystemService(Context.BLUETOOTH_SERVICE) } returns mBtManager + every { + context.checkPermission( + btPermission, + Process.myPid(), + Process.myUid() + ) + } returns PackageManager.PERMISSION_DENIED + every { mBtManager.adapter } returns mBtAdapter + + val device = mockk() + every { device.address } returns "66:77:88:99:AA:BB" + every { device.name } returns "iNet Box" + every { device.type } returns 2 + + every { + ActivityCompat.checkSelfPermission( + context, + Manifest.permission.BLUETOOTH + ) + } returns PackageManager.PERMISSION_DENIED + every { + ActivityCompat.checkSelfPermission( + mockContext, + Manifest.permission.BLUETOOTH_CONNECT + ) + } returns PackageManager.PERMISSION_DENIED + + every { TextUtils.equals(any(), any()) } returns true + every { NotificationManagerCompat.from(context).areNotificationsEnabled() } returns true + // Call the function + val result = sut.isClassicBonding(device, context, buildConfig) + + // Assert that the result is false due to denied permission + assertThat(result).isFalse() + } + + @Test + fun `test device is classic returns true`() { + // Mock permission check to simulate granted permission + val mockContext = mockk() + every { + ActivityCompat.checkSelfPermission( + mockContext, + Manifest.permission.BLUETOOTH_CONNECT + ) + } returns PackageManager.PERMISSION_GRANTED + + // Mock device type to return CLASSIC + every { bluetoothDevice.type } returns BluetoothDevice.DEVICE_TYPE_CLASSIC + + // Call the function + val result = sut.isClassicBonding(bluetoothDevice, null, null) + + // Assert that the result is true for a classic device + assertThat(result).isTrue() + } + + @Test + fun `test device is dual returns true`() { + // Mock permission check to simulate granted permission + val mockContext = mockk() + every { + ActivityCompat.checkSelfPermission( + mockContext, + Manifest.permission.BLUETOOTH_CONNECT + ) + } returns PackageManager.PERMISSION_GRANTED + + // Mock device type to return DUAL + every { bluetoothDevice.type } returns BluetoothDevice.DEVICE_TYPE_DUAL + + // Call the function + val result = sut.isClassicBonding(bluetoothDevice, null, null) + + // Assert that the result is true for a dual device + assertThat(result).isTrue() + } + + @Test + fun `test device is neither classic nor dual returns false`() { + // Mock permission check to simulate granted permission + val mockContext = mockk() + every { + ActivityCompat.checkSelfPermission( + mockContext, + Manifest.permission.BLUETOOTH_CONNECT + ) + } returns PackageManager.PERMISSION_GRANTED + + // Mock device type to return something else (e.g., LE) + every { bluetoothDevice.type } returns BluetoothDevice.DEVICE_TYPE_LE + + // Call the function + val result = sut.isClassicBonding(bluetoothDevice, null, null) + + // Assert that the result is false for non-classic/non-dual devices + assertThat(result).isFalse() + } + + @Test + fun `test exception handling returns false`() { + // Simulate an exception during permission check + val mockContext = mockk() + every { + ActivityCompat.checkSelfPermission( + mockContext, + Manifest.permission.BLUETOOTH_CONNECT + ) + } throws RuntimeException("Simulated exception") + + // Call the function + val result = sut.isClassicBonding(bluetoothDevice, null, null) + + // Assert that the result is false due to exception + assertThat(result).isFalse() + } + } + + @Nested + @DisplayName("Remove bonded device") + inner class RemoveBondedDeviceTest { + + @BeforeEach + fun setup() { + mockkStatic(Log::class) + mockkStatic(TextUtils::class) + mockkStatic(NotificationManagerCompat::class) + mockkStatic(ActivityCompat::class) + mockkStatic(Process::class) + every { Log.v(any(), any()) } returns 0 + every { Log.d(any(), any()) } returns 0 + every { Log.i(any(), any()) } returns 0 + every { Log.e(any(), any()) } returns 0 + every { bleDevice.bluetoothDevice }.returns(bluetoothDevice) + every { bluetoothDevice.type } returns 2 + } + + // todo: fix test + /*@Test + fun removeInetBoxBonding() { + val context = mockk() + val mBtManager = mockk() + val mBtAdapter = mockk() + val buildConfig = mockk() + + every { context.getSystemService(Context.BLUETOOTH_SERVICE) } returns mBtManager +// every { context.getSystemService("android.permission.POST_NOTIFICATIONS") } returns mBtManager + every { mBtManager.adapter } returns mBtAdapter + every { mBtAdapter.bondedDevices } returns setOf(bluetoothDevice) + + every { buildConfig.getVersionSDKInt() } returns 34 + every { Process.myPid() } returns 1234 + every { Process.myUid() } returns 5678 + + every { + ActivityCompat.checkSelfPermission( + context, + Manifest.permission.BLUETOOTH_ADMIN + ) + } returns PackageManager.PERMISSION_GRANTED + every { TextUtils.equals(any(), any()) } returns true + every { NotificationManagerCompat.from(context).areNotificationsEnabled() } returns true + + every { bluetoothDevice.address } returns deviceId + every { bluetoothDevice.name } returns "iNet Box" + + + val result = + sut.removeInetBoxBonding(deviceId, forceDelete = false, context) + assertThat(result).isFalse() + }*/ + } + + } diff --git a/packages/reactive_ble_mobile/pubspec.lock b/packages/reactive_ble_mobile/pubspec.lock index 717ff804..3117ef61 100644 --- a/packages/reactive_ble_mobile/pubspec.lock +++ b/packages/reactive_ble_mobile/pubspec.lock @@ -149,10 +149,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" convert: dependency: transitive description: @@ -283,6 +283,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" logging: dependency: transitive description: @@ -295,26 +319,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.12.0" mime: dependency: transitive description: @@ -343,10 +367,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" pedantic: dependency: transitive description: @@ -398,11 +422,9 @@ packages: reactive_ble_platform_interface: dependency: "direct main" description: - path: "packages/reactive_ble_platform_interface" - ref: "v1.1.122" - resolved-ref: a4841293194e9f77843c5479d1622f6c66438d1e - url: "https://github.com/ben91187/flutter_reactive_ble.git" - source: git + path: "../reactive_ble_platform_interface" + relative: true + source: path version: "5.0.2" shelf: dependency: transitive @@ -445,18 +467,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" stream_transform: dependency: transitive description: @@ -485,10 +507,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.7.0" timing: dependency: transitive description: @@ -513,22 +535,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - watcher: + vm_service: dependency: transitive description: - name: watcher - sha256: "68173f2fa67d241323a4123be7ed4e43424c54befa5505d71c8ad4b7baf8f71d" + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "1.0.0" - web: + version: "14.2.1" + watcher: dependency: transitive description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + name: watcher + sha256: "68173f2fa67d241323a4123be7ed4e43424c54befa5505d71c8ad4b7baf8f71d" url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "1.0.0" web_socket_channel: dependency: transitive description: @@ -546,5 +568,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=3.1.0 <4.0.0" - flutter: ">=2.0.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/packages/reactive_ble_mobile/pubspec.yaml b/packages/reactive_ble_mobile/pubspec.yaml index ea4cc8a3..a64f4f8d 100644 --- a/packages/reactive_ble_mobile/pubspec.yaml +++ b/packages/reactive_ble_mobile/pubspec.yaml @@ -15,7 +15,9 @@ dependencies: git: url: https://github.com/ben91187/flutter_reactive_ble.git path: packages/reactive_ble_platform_interface - ref: v1.1.127 + ref: v2.0.0 +# reactive_ble_platform_interface: +# path: ../reactive_ble_platform_interface dev_dependencies: build_runner: ^2.1.2 flutter_test: diff --git a/packages/reactive_ble_platform_interface/pubspec.lock b/packages/reactive_ble_platform_interface/pubspec.lock index 57d3c2c6..d365e647 100644 --- a/packages/reactive_ble_platform_interface/pubspec.lock +++ b/packages/reactive_ble_platform_interface/pubspec.lock @@ -133,18 +133,18 @@ packages: dependency: transitive description: name: code_builder - sha256: "0d43dd1288fd145de1ecc9a3948ad4a6d5a82f0a14c4fdd0892260787d975cbe" + sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.10.0" collection: dependency: "direct main" description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" convert: dependency: transitive description: @@ -291,6 +291,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -311,26 +335,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: "direct main" description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.12.0" mime: dependency: transitive description: @@ -343,10 +367,10 @@ packages: dependency: "direct dev" description: name: mockito - sha256: "8b46d7eb40abdda92d62edd01546051f0c27365e65608c284de336dccfef88cc" + sha256: "6841eed20a7befac0ce07df8116c8b8233ed1f4486a7647c7fc5a02ae6163917" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "5.4.4" package_config: dependency: transitive description: @@ -359,10 +383,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" plugin_platform_interface: dependency: "direct main" description: @@ -436,18 +460,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" stream_transform: dependency: transitive description: @@ -476,10 +500,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.7.0" timing: dependency: transitive description: @@ -504,22 +528,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - watcher: + vm_service: dependency: transitive description: - name: watcher - sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "1.0.2" - web: + version: "14.2.1" + watcher: dependency: transitive description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + name: watcher + sha256: "6a7f46926b01ce81bfc339da6a7f20afbe7733eff9846f6d6a5466aa4c6667c0" url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "1.0.2" web_socket_channel: dependency: transitive description: @@ -537,5 +561,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=2.0.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54"