diff --git a/.github/workflows/wifi_scan.yaml b/.github/workflows/wifi_scan.yaml new file mode 100644 index 00000000..b58050af --- /dev/null +++ b/.github/workflows/wifi_scan.yaml @@ -0,0 +1,91 @@ +# Build wifi_scan example +name: wifi_scan + +on: + pull_request: + paths: + - "packages/wifi_scan/**" + - ".github/workflows/wifi_scan.yaml" + +env: + PLUGIN_SCOPE: "*wifi_scan*" + PLUGIN_EXAMPLE_SCOPE: "*wifi_scan_example*" + +jobs: + android: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: "Checkout repository" + uses: actions/checkout@v2 + - name: "Install Flutter" + run: ./.github/workflows/scripts/install-flutter.sh stable + - name: "Install Tools" + run: ./.github/workflows/scripts/install-tools.sh + - name: "Build Example" + run: ./.github/workflows/scripts/build-examples.sh android ./lib/main.dart + + ios: + runs-on: macos-latest + timeout-minutes: 30 + steps: + - name: "Checkout repository" + uses: actions/checkout@v2 + - name: "Install Flutter" + run: ./.github/workflows/scripts/install-flutter.sh stable + - name: "Install Tools" + run: ./.github/workflows/scripts/install-tools.sh + - name: "Build Example" + run: ./.github/workflows/scripts/build-examples.sh ios ./lib/main.dart + +# macos: +# runs-on: macos-latest +# timeout-minutes: 30 +# steps: +# - name: "Checkout repository" +# uses: actions/checkout@v2 +# - name: "Install Flutter" +# run: ./.github/workflows/scripts/install-flutter.sh stable +# - name: "Install Tools" +# run: ./.github/workflows/scripts/install-tools.sh +# - name: "Build Example" +# run: ./.github/workflows/scripts/build-examples.sh macos ./lib/main.dart + +# linux: +# runs-on: ubuntu-latest +# timeout-minutes: 30 +# steps: +# - name: "Checkout repository" +# uses: actions/checkout@v2 +# - name: "Install Flutter" +# run: ./.github/workflows/scripts/install-flutter.sh stable +# - name: "Install Tools" +# run: ./.github/workflows/scripts/install-tools.sh +# - name: "Build Example" +# run: ./.github/workflows/scripts/build-examples.sh linux ./lib/main.dart + +# windows: +# runs-on: ubuntu-latest +# timeout-minutes: 30 +# steps: +# - name: "Checkout repository" +# uses: actions/checkout@v2 +# - name: "Install Flutter" +# run: ./.github/workflows/scripts/install-flutter.sh stable +# - name: "Install Tools" +# run: ./.github/workflows/scripts/install-tools.sh +# - name: "Build Example" +# run: ./.github/workflows/scripts/build-examples.sh windows ./lib/main.dart + +# web: +# runs-on: ubuntu-latest +# timeout-minutes: 30 +# steps: +# - name: "Checkout repository" +# uses: actions/checkout@v2 +# - name: "Install Flutter" +# run: ./.github/workflows/scripts/install-flutter.sh stable +# - name: "Install Tools" +# run: ./.github/workflows/scripts/install-tools.sh +# - name: "Build Example" +# run: ./.github/workflows/scripts/build-examples.sh web ./lib/main.dart \ No newline at end of file diff --git a/README.md b/README.md index 6f8433d8..344845c3 100644 --- a/README.md +++ b/README.md @@ -72,14 +72,14 @@ Flutter plugin for basic WiFi information and functionalities. ### `wifi_scan` > [![wifi_scan][scan_workflow_badge]][scan_workflow] [![wifi_scan][scan_pub_badge]][scan_pub] [![pub points][scan_pub_points_badge]][scan_pub_points] -Flutter plugin to scan for WiFi networks. +Flutter plugin to scan for WiFi access points. [[View Source][scan_code]] #### Platform Support | Android | iOS | | :-----: | :-: | -| ❌ | ➖ | +| ✔️ | | --- diff --git a/packages/wifi_scan/.gitignore b/packages/wifi_scan/.gitignore new file mode 100644 index 00000000..e9dc58d3 --- /dev/null +++ b/packages/wifi_scan/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +.dart_tool/ + +.packages +.pub/ + +build/ diff --git a/packages/wifi_scan/.metadata b/packages/wifi_scan/.metadata new file mode 100644 index 00000000..5bed5265 --- /dev/null +++ b/packages/wifi_scan/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 18116933e77adc82f80866c928266a5b4f1ed645 + channel: stable + +project_type: plugin diff --git a/packages/wifi_scan/CHANGELOG.md b/packages/wifi_scan/CHANGELOG.md new file mode 100644 index 00000000..41cc7d81 --- /dev/null +++ b/packages/wifi_scan/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/packages/wifi_scan/LICENSE b/packages/wifi_scan/LICENSE new file mode 100644 index 00000000..d36bc92e --- /dev/null +++ b/packages/wifi_scan/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 AlternaDom + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/wifi_scan/README.md b/packages/wifi_scan/README.md new file mode 100644 index 00000000..4bad3c3e --- /dev/null +++ b/packages/wifi_scan/README.md @@ -0,0 +1,144 @@ +

WiFiFlutter| wifi_scan

+ +

+ + analysis + + + pub.dev + + + pub points + + + popularity + + + likes + +

+ +--- +This plugin allows Flutter apps to trigger WiFi scan and get scanned results. + +> This plugin is part of [WiFiFlutter][wf_home] suite, enabling various WiFi services for Flutter. + +## Platform Support + +| Platform | Status | Min. Version | API | Notes | +| :------: | :----: |:------------:| :---: |:-----:| +| **Android** | ✔️ | 16 (J) | Scan related APIs in [`WifiManager`][android_WifiManager] *[[Guide][android_guide]]* | For SDK >= 26(O) scans are [throttled][android_throttling]. | +| **iOS** | ✔️ | 9.0 | No API available | Dummy implementation with [sane static returns][ios_dummy]. | + +## Usage +The entry point for the plugin is the singleton instance `WiFiScan.instance`. + +### Start scan +You can trigger full WiFi scan with `WiFiScan.startScan` API, as shown below: +```dart +// check if platform support and necessary requirements +final can = await WiFiScan.instance.canStartScan(askPermissions: true); +switch(can) { + case CanStartScan.yes: + // start full scan async-ly + final isScanning = await WiFiScan.instance.startScan(); + //... + break; + // ... handle other cases of CanStartScan values +} +``` + +For more details, you can read documentation of [`WiFiScan.startScan`][doc_startScan], [`WiFiScan.canStartScan`][doc_canStartScan] and [`CanStartScan`][doc_enum_CanStartScan]. + +### Get scanned results +You can get scanned results with `WiFiScan.getScannedResults` API, as shown below: +```dart +// check if platform support and necessary requirements +final can = await WiFiScan.instance.canGetScannedResults(askPermissions: true); +switch(can) { + case CanGetScannedResults.yes: + // get scanned results + final accessPoints = await WiFiScan.instance.getScannedResults(); + // ... + break; + // ... handle other cases of CanGetScannedResults values +} +``` + +> **NOTE:** `getScannedResults` API can be used independently of `startScan` API. This returns the latest available scanned results. + +For more details, you can read documentation of [`WiFiScan.getScannedResults`][doc_getScannedResults], `WiFiAccessPoint`[doc_WiFiAccessPoint], [`WiFiScan.canGetScannedResults`][doc_canGetScannedResults] and [`CanGetScannedResults`][doc_enum_CanGetScannedResults]. + +### Get notified when scanned results available +You can get notified when new scanned results are available, as shown below: +```dart +// initialize accessPoints and subscription +List accessPoints = []; +StreamSubscription>? subscription; + +void _startListeningToScannedResults(){ +// check if platform support and necessary requirements + final can = await WiFiScan.instance.canGetScannedResults(askPermissions: true); + switch(can) { + case CanGetScannedResults.yes: + // listen to onScannedResultsAvailable stream + subscription = WiFiScan.instance.onScannedResultsAvailable.listen((results) { + // update accessPoints + setState(() => accessPoints = results); + }); + // ... + break; + // ... handle other cases of CanGetScannedResults values + } +} + +// make sure to cancel subscription after you are done +@override +dispose() { + super.dispose(); + subscription?.cancel(); +} +``` + +Additionally, `WiFiScan.onScannedResultsAvailable` API can also be used with Flutter's [`StreamBuilder`][flutter_StreamBuilder] widget. + +> **NOTE:** `onScannedResultsAvailable` API can be used independently of `startScan` API. The notification can also be result of a full scan performed by platform or other app. + +For more details, you can read documentation of [`WiFiScan.onScannedResultsAvailable`][doc_onScannedResultsAvailable], `WiFiAccessPoint`[doc_WiFiAccessPoint], [`WiFiScan.canGetScannedResults`][doc_canGetScannedResults] and [`CanGetScannedResults`][doc_enum_CanGetScannedResults]. + +## Resources +- 📖[API docs][docs] +- 💻[Example app][example] + +## Issues and feedback + +Please file WiFiFlutter specific issues, bugs, or feature requests in our [issue tracker][wf_issue]. + +To contribute a change to this plugin, please review plugin [checklist for 1.0][checklist], our [contribution guide][wf_contrib] and open a [pull request][wf_pull]. + + +[wf_home]: https://wifi.flutternetwork.dev/ +[wf_issue]: https://github.com/flutternetwork/WiFiFlutter/issues/new +[wf_contrib]: https://github.com/flutternetwork/WiFiFlutter/blob/master/CONTRIBUTING.md +[wf_pull]: https://github.com/flutternetwork/WiFiFlutter/pulls + +[checklist]: https://github.com/flutternetwork/WiFiFlutter/issues/188 +[docs]: https://pub.dev/documentation/wifi_scan/latest/wifi_scan/wifi_scan-library.html +[example]: https://github.com/flutternetwork/WiFiFlutter/tree/master/packages/wifi_scan/example + +[doc_startScan]: https://pub.dev/documentation/wifi_scan/latest/wifi_scan/WiFiScan/startScan.html +[doc_canStartScan]: https://pub.dev/documentation/wifi_scan/latest/wifi_scan/WiFiScan/canStartScan.html +[doc_enum_CanStartScan]: https://pub.dev/documentation/wifi_scan/latest/wifi_scan/CanStartScan.html +[doc_getScannedResults]: https://pub.dev/documentation/wifi_scan/latest/wifi_scan/WiFiScan/getScannedResults.html +[doc_WiFiAccessPoint]: https://pub.dev/documentation/wifi_scan/latest/wifi_scan/WiFiAccessPoint.html +[doc_canGetScannedResults]: https://pub.dev/documentation/wifi_scan/latest/wifi_scan/WiFiScan/canGetScannedResults.html +[doc_enum_CanGetScannedResults]: https://pub.dev/documentation/wifi_scan/latest/wifi_scan/CanGetScannedResults.html +[doc_onScannedResultsAvailable]: https://pub.dev/documentation/wifi_scan/latest/wifi_scan/WiFiScan/onScannedResultsAvailable.html + +[flutter_StreamBuilder]: https://api.flutter.dev/flutter/widgets/StreamBuilder-class.html + +[android_guide]: https://developer.android.com/guide/topics/connectivity/wifi-scan +[android_throttling]: https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-throttling +[android_WifiManager]: https://developer.android.com/reference/android/net/wifi/WifiManager + +[ios_dummy]: https://github.com/flutternetwork/WiFiFlutter/blob/master/packages/wifi_scan/ios/Classes/SwiftWifiScanPlugin.swift diff --git a/packages/wifi_scan/android/.gitignore b/packages/wifi_scan/android/.gitignore new file mode 100644 index 00000000..c6cbe562 --- /dev/null +++ b/packages/wifi_scan/android/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/packages/wifi_scan/android/build.gradle b/packages/wifi_scan/android/build.gradle new file mode 100644 index 00000000..32ba7bfc --- /dev/null +++ b/packages/wifi_scan/android/build.gradle @@ -0,0 +1,50 @@ +group 'dev.flutternetwork.wifi.wifi_scan' +version '1.0-SNAPSHOT' + +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 30 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + minSdkVersion 16 + } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/packages/wifi_scan/android/gradle.properties b/packages/wifi_scan/android/gradle.properties new file mode 100644 index 00000000..94adc3a3 --- /dev/null +++ b/packages/wifi_scan/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/packages/wifi_scan/android/gradle/wrapper/gradle-wrapper.properties b/packages/wifi_scan/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..3c9d0852 --- /dev/null +++ b/packages/wifi_scan/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/packages/wifi_scan/android/settings.gradle b/packages/wifi_scan/android/settings.gradle new file mode 100644 index 00000000..a528fecb --- /dev/null +++ b/packages/wifi_scan/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'wifi_scan' diff --git a/packages/wifi_scan/android/src/main/AndroidManifest.xml b/packages/wifi_scan/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..54f7b9a0 --- /dev/null +++ b/packages/wifi_scan/android/src/main/AndroidManifest.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/packages/wifi_scan/android/src/main/kotlin/dev/flutternetwork/wifi/wifi_scan/WifiScanPlugin.kt b/packages/wifi_scan/android/src/main/kotlin/dev/flutternetwork/wifi/wifi_scan/WifiScanPlugin.kt new file mode 100644 index 00000000..db0a1b53 --- /dev/null +++ b/packages/wifi_scan/android/src/main/kotlin/dev/flutternetwork/wifi/wifi_scan/WifiScanPlugin.kt @@ -0,0 +1,328 @@ +package dev.flutternetwork.wifi.wifi_scan + +import android.Manifest +import android.app.Activity +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.content.pm.PackageManager +import android.location.LocationManager +import android.net.wifi.WifiManager +import android.os.Build +import android.util.Log +import androidx.annotation.NonNull +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat +import androidx.core.location.LocationManagerCompat +import io.flutter.embedding.engine.plugins.FlutterPlugin +import io.flutter.embedding.engine.plugins.activity.ActivityAware +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding +import io.flutter.plugin.common.EventChannel +import io.flutter.plugin.common.EventChannel.EventSink +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.MethodChannel.MethodCallHandler +import io.flutter.plugin.common.MethodChannel.Result +import io.flutter.plugin.common.PluginRegistry +import kotlin.random.Random + +/** Error Codes */ +private const val ERROR_INVALID_ARGS = "InvalidArgs" +private const val ERROR_NULL_ACTIVITY = "NullActivity" + +/** CanStartScan codes */ +private const val CAN_START_SCAN_NOT_SUPPORTED = 0 +private const val CAN_START_SCAN_YES = 1 +private const val CAN_START_SCAN_NO_LOC_PERM_REQUIRED = 2 +private const val CAN_START_SCAN_NO_LOC_PERM_DENIED = 3 +private const val CAN_START_SCAN_NO_LOC_PERM_UPGRADE_ACCURACY = 4 +private const val CAN_START_SCAN_NO_LOC_DISABLED = 5 + +/** CanGetScannedResults codes */ +private const val CAN_GET_RESULTS_NOT_SUPPORTED = 0 +private const val CAN_GET_RESULTS_YES = 1 +private const val CAN_GET_RESULTS_NO_LOC_PERM_REQUIRED = 2 +private const val CAN_GET_RESULTS_NO_LOC_PERM_DENIED = 3 +private const val CAN_GET_RESULTS_NO_LOC_PERM_UPGRADE_ACCURACY = 4 +private const val CAN_GET_RESULTS_NO_LOC_DISABLED = 5 + +/** Magic codes */ +private const val ASK_FOR_LOC_PERM = -1 + +/** WifiScanPlugin + * + * Useful links: + * - https://developer.android.com/guide/topics/connectivity/wifi-scan + * - https://developer.android.com/reference/android/net/wifi/WifiManager + * - https://developer.android.com/reference/android/net/wifi/ScanResult + * - https://developer.android.com/training/location/permissions + * */ +class WifiScanPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, + PluginRegistry.RequestPermissionsResultListener, EventChannel.StreamHandler { + private val logTag = javaClass.simpleName + private lateinit var context: Context + private var activity: Activity? = null + private var wifi: WifiManager? = null + private var wifiScanReceiver: BroadcastReceiver? = null + private val requestPermissionCookie = mutableMapOf Boolean>() + private val locationPermissionCoarse = arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION) + private val locationPermissionFine = arrayOf(Manifest.permission.ACCESS_FINE_LOCATION) + private val locationPermissionBoth = locationPermissionCoarse + locationPermissionFine + + // plugin interfaces + private lateinit var channel: MethodChannel + private lateinit var eventChannel: EventChannel + // single sink - to send + private var eventSink: EventSink? = null + + override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { + context = flutterPluginBinding.applicationContext + wifi = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager + // set broadcast receiver - listening for new scannedResults + wifiScanReceiver = object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + if (intent.getBooleanExtra(WifiManager.EXTRA_RESULTS_UPDATED, false)) { + eventSink?.success(getScannedResults()) + } + } + } + val intentFilter = IntentFilter() + intentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) + context.registerReceiver(wifiScanReceiver, intentFilter) + + // set Flutter channels - 1 for method, 1 for event + channel = MethodChannel(flutterPluginBinding.binaryMessenger, "wifi_scan") + channel.setMethodCallHandler(this) + eventChannel = EventChannel(flutterPluginBinding.binaryMessenger, + "wifi_scan/onScannedResultsAvailable") + eventChannel.setStreamHandler(this) + } + + override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { + channel.setMethodCallHandler(null) + eventChannel.setStreamHandler(null) + wifi = null + context.unregisterReceiver(wifiScanReceiver) + wifiScanReceiver = null + } + + + override fun onAttachedToActivity(binding: ActivityPluginBinding) { + activity = binding.activity + binding.addRequestPermissionsResultListener(this) + } + + override fun onDetachedFromActivityForConfigChanges() { + activity = null + } + + override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { + activity = binding.activity + binding.addRequestPermissionsResultListener(this) + } + + override fun onDetachedFromActivity() { + activity = null + } + + override fun onListen(arguments: Any?, events: EventSink?) { + eventSink = events + // put getScannedResults in sink - to start with + eventSink?.success(getScannedResults()) + } + + override fun onCancel(arguments: Any?) { + eventSink?.endOfStream() + eventSink = null + } + + override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { + when (call.method) { + "canStartScan" -> { + val askPermission = call.argument("askPermissions") ?: return result.error( + ERROR_INVALID_ARGS, + "askPermissions argument is null", + null + ) + when (val canCode = canStartScan(askPermission)) { + ASK_FOR_LOC_PERM -> askForLocationPermission {askResult -> + when (askResult) { + AskLocPermResult.GRANTED -> { + result.success(canStartScan(askPermission = false)) + } + AskLocPermResult.UPGRADE_TO_FINE -> { + result.success(CAN_START_SCAN_NO_LOC_PERM_UPGRADE_ACCURACY) + } + AskLocPermResult.DENIED -> { + result.success(CAN_START_SCAN_NO_LOC_PERM_DENIED) + } + AskLocPermResult.ERROR_NO_ACTIVITY -> { + result.error( + ERROR_NULL_ACTIVITY, + "Cannot ask for location permission.", + "Looks like called from non-Activity." + ) + } + } + } + else -> result.success(canCode) + } + } + "startScan" -> result.success(startScan()) + "canGetScannedResults" -> { + val askPermission = call.argument("askPermissions") ?: return result.error( + ERROR_INVALID_ARGS, + "askPermissions argument is null", + null + ) + when (val canCode = canGetScannedResults(askPermission)) { + ASK_FOR_LOC_PERM -> askForLocationPermission { askResult -> + when (askResult) { + AskLocPermResult.GRANTED -> { + result.success(canGetScannedResults(askPermission = false)) + } + AskLocPermResult.UPGRADE_TO_FINE -> { + result.success(CAN_GET_RESULTS_NO_LOC_PERM_UPGRADE_ACCURACY) + } + AskLocPermResult.DENIED -> { + result.success(CAN_GET_RESULTS_NO_LOC_PERM_DENIED) + } + AskLocPermResult.ERROR_NO_ACTIVITY -> { + result.error( + ERROR_NULL_ACTIVITY, + "Cannot ask for location permission.", + "Looks like called from non-Activity." + ) + } + } + } + else -> result.success(canCode) + } + } + "getScannedResults" -> result.success(getScannedResults()) + else -> result.notImplemented() + } + } + + + override fun onRequestPermissionsResult( + requestCode: Int, permissions: Array?, grantResults: IntArray? + ): Boolean { + Log.d(logTag, "onRequestPermissionsResult: arguments ($requestCode, $permissions, $grantResults)") + if (grantResults != null) { + Log.d(logTag, "requestPermissionCookie: $requestPermissionCookie") + return requestPermissionCookie[requestCode]?.invoke(grantResults) ?: false + } + return false + } + + /** + * ACCESS_FINE_LOCATION required for: SDK >= Q[29] and tSDK >= Q[29] + */ + private fun requiresFineLocation(): Boolean = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && context.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.Q + + private fun hasLocationPermission(): Boolean { + val permissions = when { + requiresFineLocation() -> locationPermissionFine + else -> locationPermissionBoth + } + return permissions.any { permission -> + ContextCompat.checkSelfPermission(context, + permission) == PackageManager.PERMISSION_GRANTED + } + } + + private enum class AskLocPermResult { + GRANTED, UPGRADE_TO_FINE, DENIED, ERROR_NO_ACTIVITY + } + + private fun askForLocationPermission(callback: (AskLocPermResult) -> Unit) { + // check if has activity - return error if null + if (activity == null) return callback.invoke(AskLocPermResult.ERROR_NO_ACTIVITY) + // make permissions + val requiresFine = requiresFineLocation() + // - for SDK > R[30] - cannot only ask for FINE + val requiresFineButAskBoth = requiresFine && Build.VERSION.SDK_INT > Build.VERSION_CODES.R + val permissions = when { + requiresFineButAskBoth -> locationPermissionBoth + requiresFine -> locationPermissionFine + else -> locationPermissionCoarse + } + // request permission - add result-handler in requestPermissionCookie + val permissionCode = 6560000 + Random.Default.nextInt(10000) + requestPermissionCookie[permissionCode] = { grantArray -> + // invoke callback with proper askResult + Log.d(logTag, "permissionResultCallback: args($grantArray)") + callback.invoke( + when { + // GRANTED: if all granted + grantArray.all { it == PackageManager.PERMISSION_GRANTED } -> { + AskLocPermResult.GRANTED + } + // UPGRADE_TO_FINE: if requiresFineButAskBoth and COARSE granted + requiresFineButAskBoth && grantArray.first() == PackageManager.PERMISSION_GRANTED -> { + AskLocPermResult.UPGRADE_TO_FINE + } + else -> AskLocPermResult.DENIED + } + ) + true + } + ActivityCompat.requestPermissions(activity!!, permissions, permissionCode) + } + + private fun isLocationEnabled(): Boolean = + LocationManagerCompat.isLocationEnabled( + context.applicationContext.getSystemService(Context.LOCATION_SERVICE) as LocationManager + ) + + private fun canStartScan(askPermission: Boolean): Int { + val hasLocPerm = hasLocationPermission() + val isLocEnabled = isLocationEnabled() + return when { + // for SDK < P[28] : Not in guide, should not require any additional permissions + Build.VERSION.SDK_INT < Build.VERSION_CODES.P -> CAN_START_SCAN_YES + // for SDK >= Q[29]: CHANGE_WIFI_STATE & ACCESS_x_LOCATION & "Location enabled" + hasLocPerm && isLocEnabled -> CAN_START_SCAN_YES + hasLocPerm -> CAN_START_SCAN_NO_LOC_DISABLED + askPermission -> ASK_FOR_LOC_PERM + else -> CAN_START_SCAN_NO_LOC_PERM_REQUIRED + } + } + + private fun startScan(): Boolean = wifi!!.startScan() + + private fun canGetScannedResults(askPermission: Boolean): Int { + // ACCESS_WIFI_STATE & ACCESS_x_LOCATION & "Location enabled" + val hasLocPerm = hasLocationPermission() + val isLocEnabled = isLocationEnabled() + return when { + hasLocPerm && isLocEnabled -> CAN_GET_RESULTS_YES + hasLocPerm -> CAN_GET_RESULTS_NO_LOC_DISABLED + askPermission -> ASK_FOR_LOC_PERM + else -> CAN_GET_RESULTS_NO_LOC_PERM_REQUIRED + } + } + + + private fun getScannedResults(): List> = wifi!!.scanResults.map { ap -> + mapOf( + "ssid" to ap.SSID, + "bssid" to ap.BSSID, + "capabilities" to ap.capabilities, + "frequency" to ap.frequency, + "level" to ap.level, + "timestamp" to if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) ap.timestamp else null, + "standard" to if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) ap.wifiStandard else null, + "centerFrequency0" to if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ap.centerFreq0 else null, + "centerFrequency1" to if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ap.centerFreq1 else null, + "channelWidth" to if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ap.channelWidth else null, + "isPasspoint" to if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ap.isPasspointNetwork else null, + "operatorFriendlyName" to if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ap.operatorFriendlyName else null, + "venueName" to if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ap.venueName else null, + "is80211mcResponder" to if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) ap.is80211mcResponder else null + ) + } +} diff --git a/packages/wifi_scan/example/.gitignore b/packages/wifi_scan/example/.gitignore new file mode 100644 index 00000000..0fa6b675 --- /dev/null +++ b/packages/wifi_scan/example/.gitignore @@ -0,0 +1,46 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/packages/wifi_scan/example/.metadata b/packages/wifi_scan/example/.metadata new file mode 100644 index 00000000..a5584fc3 --- /dev/null +++ b/packages/wifi_scan/example/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 18116933e77adc82f80866c928266a5b4f1ed645 + channel: stable + +project_type: app diff --git a/packages/wifi_scan/example/README.md b/packages/wifi_scan/example/README.md new file mode 100644 index 00000000..a83809be --- /dev/null +++ b/packages/wifi_scan/example/README.md @@ -0,0 +1,16 @@ +# wifi_scan_example + +Demonstrates how to use the wifi_scan plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/packages/wifi_scan/example/android/.gitignore b/packages/wifi_scan/example/android/.gitignore new file mode 100644 index 00000000..6f568019 --- /dev/null +++ b/packages/wifi_scan/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/packages/wifi_scan/example/android/app/build.gradle b/packages/wifi_scan/example/android/app/build.gradle new file mode 100644 index 00000000..81523995 --- /dev/null +++ b/packages/wifi_scan/example/android/app/build.gradle @@ -0,0 +1,68 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion flutter.compileSdkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "dev.flutternetwork.wifi.wifi_scan_example" + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/packages/wifi_scan/example/android/app/src/debug/AndroidManifest.xml b/packages/wifi_scan/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000..ccfbce9d --- /dev/null +++ b/packages/wifi_scan/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/packages/wifi_scan/example/android/app/src/main/AndroidManifest.xml b/packages/wifi_scan/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..b0fd83fd --- /dev/null +++ b/packages/wifi_scan/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + diff --git a/packages/wifi_scan/example/android/app/src/main/kotlin/dev/flutternetwork/wifi/wifi_scan_example/MainActivity.kt b/packages/wifi_scan/example/android/app/src/main/kotlin/dev/flutternetwork/wifi/wifi_scan_example/MainActivity.kt new file mode 100644 index 00000000..6ea3a678 --- /dev/null +++ b/packages/wifi_scan/example/android/app/src/main/kotlin/dev/flutternetwork/wifi/wifi_scan_example/MainActivity.kt @@ -0,0 +1,6 @@ +package dev.flutternetwork.wifi.wifi_scan_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/packages/wifi_scan/example/android/app/src/main/res/drawable-v21/launch_background.xml b/packages/wifi_scan/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 00000000..f74085f3 --- /dev/null +++ b/packages/wifi_scan/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/packages/wifi_scan/example/android/app/src/main/res/drawable/launch_background.xml b/packages/wifi_scan/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 00000000..304732f8 --- /dev/null +++ b/packages/wifi_scan/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/packages/wifi_scan/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/packages/wifi_scan/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 00000000..db77bb4b Binary files /dev/null and b/packages/wifi_scan/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/packages/wifi_scan/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/packages/wifi_scan/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 00000000..17987b79 Binary files /dev/null and b/packages/wifi_scan/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/packages/wifi_scan/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/packages/wifi_scan/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 00000000..09d43914 Binary files /dev/null and b/packages/wifi_scan/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/packages/wifi_scan/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/packages/wifi_scan/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..d5f1c8d3 Binary files /dev/null and b/packages/wifi_scan/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/packages/wifi_scan/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/packages/wifi_scan/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 00000000..4d6372ee Binary files /dev/null and b/packages/wifi_scan/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/packages/wifi_scan/example/android/app/src/main/res/values-night/styles.xml b/packages/wifi_scan/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 00000000..449a9f93 --- /dev/null +++ b/packages/wifi_scan/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/packages/wifi_scan/example/android/app/src/main/res/values/styles.xml b/packages/wifi_scan/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 00000000..d74aa35c --- /dev/null +++ b/packages/wifi_scan/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/packages/wifi_scan/example/android/app/src/profile/AndroidManifest.xml b/packages/wifi_scan/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 00000000..ccfbce9d --- /dev/null +++ b/packages/wifi_scan/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/packages/wifi_scan/example/android/build.gradle b/packages/wifi_scan/example/android/build.gradle new file mode 100644 index 00000000..ed45c658 --- /dev/null +++ b/packages/wifi_scan/example/android/build.gradle @@ -0,0 +1,29 @@ +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/packages/wifi_scan/example/android/gradle.properties b/packages/wifi_scan/example/android/gradle.properties new file mode 100644 index 00000000..94adc3a3 --- /dev/null +++ b/packages/wifi_scan/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/packages/wifi_scan/example/android/gradle/wrapper/gradle-wrapper.properties b/packages/wifi_scan/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..bc6a58af --- /dev/null +++ b/packages/wifi_scan/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/packages/wifi_scan/example/android/settings.gradle b/packages/wifi_scan/example/android/settings.gradle new file mode 100644 index 00000000..44e62bcf --- /dev/null +++ b/packages/wifi_scan/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/packages/wifi_scan/example/ios/.gitignore b/packages/wifi_scan/example/ios/.gitignore new file mode 100644 index 00000000..7a7f9873 --- /dev/null +++ b/packages/wifi_scan/example/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/packages/wifi_scan/example/ios/Flutter/AppFrameworkInfo.plist b/packages/wifi_scan/example/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 00000000..8d4492f9 --- /dev/null +++ b/packages/wifi_scan/example/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 9.0 + + diff --git a/packages/wifi_scan/example/ios/Flutter/Debug.xcconfig b/packages/wifi_scan/example/ios/Flutter/Debug.xcconfig new file mode 100644 index 00000000..ec97fc6f --- /dev/null +++ b/packages/wifi_scan/example/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/packages/wifi_scan/example/ios/Flutter/Release.xcconfig b/packages/wifi_scan/example/ios/Flutter/Release.xcconfig new file mode 100644 index 00000000..c4855bfe --- /dev/null +++ b/packages/wifi_scan/example/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/packages/wifi_scan/example/ios/Podfile b/packages/wifi_scan/example/ios/Podfile new file mode 100644 index 00000000..1e8c3c90 --- /dev/null +++ b/packages/wifi_scan/example/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/wifi_scan/example/ios/Runner.xcodeproj/project.pbxproj b/packages/wifi_scan/example/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 00000000..1a83e33e --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,552 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + ED879899797BD40D00C7B393 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A6681C9196B2BF084ED992EA /* Pods_Runner.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 121E5D67847E04B5C947BCDE /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 82A6DCFC7EA9D7C1336EF2EA /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A6681C9196B2BF084ED992EA /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C5F3F3F716039D241CAC1708 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ED879899797BD40D00C7B393 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1CADE8A57AF19FCDC38BD916 /* Pods */ = { + isa = PBXGroup; + children = ( + C5F3F3F716039D241CAC1708 /* Pods-Runner.debug.xcconfig */, + 121E5D67847E04B5C947BCDE /* Pods-Runner.release.xcconfig */, + 82A6DCFC7EA9D7C1336EF2EA /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + 69D99339F5B441DA08C72CDB /* Frameworks */ = { + isa = PBXGroup; + children = ( + A6681C9196B2BF084ED992EA /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 1CADE8A57AF19FCDC38BD916 /* Pods */, + 69D99339F5B441DA08C72CDB /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + BDFFD52AD972BFD0CCAF76A4 /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 9119DAADF478773DD2355190 /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9119DAADF478773DD2355190 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; + BDFFD52AD972BFD0CCAF76A4 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = DC8X5UJHS6; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.flutternetwork.wifi.wifiScanExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = DC8X5UJHS6; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.flutternetwork.wifi.wifiScanExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = DC8X5UJHS6; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = dev.flutternetwork.wifi.wifiScanExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/packages/wifi_scan/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/wifi_scan/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/packages/wifi_scan/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/wifi_scan/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/wifi_scan/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/packages/wifi_scan/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/packages/wifi_scan/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/wifi_scan/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 00000000..c87d15a3 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/wifi_scan/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/packages/wifi_scan/example/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..21a3cc14 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/packages/wifi_scan/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/wifi_scan/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/wifi_scan/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/packages/wifi_scan/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..f9b0d7c5 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/packages/wifi_scan/example/ios/Runner/AppDelegate.swift b/packages/wifi_scan/example/ios/Runner/AppDelegate.swift new file mode 100644 index 00000000..70693e4a --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..d36b1fab --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 00000000..dc9ada47 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 00000000..28c6bf03 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 00000000..2ccbfd96 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 00000000..f091b6b0 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 00000000..4cde1211 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 00000000..d0ef06e7 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 00000000..dcdc2306 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 00000000..2ccbfd96 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 00000000..c8f9ed8f Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 00000000..a6d6b860 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 00000000..a6d6b860 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 00000000..75b2d164 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 00000000..c4df70d3 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 00000000..6a84f41e Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 00000000..d0e1f585 Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 00000000..0bedcf2f --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 00000000..9da19eac Binary files /dev/null and b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 00000000..89c2725b --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/packages/wifi_scan/example/ios/Runner/Base.lproj/LaunchScreen.storyboard b/packages/wifi_scan/example/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..f2e259c7 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/wifi_scan/example/ios/Runner/Base.lproj/Main.storyboard b/packages/wifi_scan/example/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 00000000..f3c28516 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/wifi_scan/example/ios/Runner/Info.plist b/packages/wifi_scan/example/ios/Runner/Info.plist new file mode 100644 index 00000000..83f86d25 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Wifi Scan + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + wifi_scan_example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/packages/wifi_scan/example/ios/Runner/Runner-Bridging-Header.h b/packages/wifi_scan/example/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 00000000..308a2a56 --- /dev/null +++ b/packages/wifi_scan/example/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/packages/wifi_scan/example/lib/main.dart b/packages/wifi_scan/example/lib/main.dart new file mode 100644 index 00000000..6cc19b29 --- /dev/null +++ b/packages/wifi_scan/example/lib/main.dart @@ -0,0 +1,201 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:wifi_scan/wifi_scan.dart'; + +void main() { + runApp(const MyApp()); +} + +/// Example app for wifi_scan plugin. +class MyApp extends StatefulWidget { + /// Default constructor for [MyApp] widget. + const MyApp({Key? key}) : super(key: key); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + bool shouldCheck = true; + bool shouldStream = true; + List accessPoints = []; + + void showSnackBar(BuildContext context, String message) { + if (kDebugMode) print(message); + ScaffoldMessenger.of(context) + ..hideCurrentSnackBar() + ..showSnackBar(SnackBar(content: Text(message))); + } + + Future _startScan(BuildContext context) async { + if (shouldCheck) { + // check if can-startScan + final can = await WiFiScan.instance.canStartScan(); + // if can-not, then show error + if (can != CanStartScan.yes) { + showSnackBar(context, "Cannot start scan: $can"); + return; + } + } + showSnackBar(context, "startScan: ${await WiFiScan.instance.startScan()}"); + } + + Future _canGetScannedResults(BuildContext context) async { + if (shouldCheck) { + // check if can-getScannedResults + final can = await WiFiScan.instance.canGetScannedResults(); + // if can-not, then show error + if (can != CanGetScannedResults.yes) { + showSnackBar(context, "Cannot get scanned results: $can"); + accessPoints = []; + return false; + } + } + return true; + } + + Widget _buildSwitch(String label, bool value, ValueChanged onChanged) => + Row( + children: [ + Text(label), + Switch(value: value, onChanged: onChanged), + ], + ); + + Widget _buildInfo(String label, dynamic value) => Container( + decoration: const BoxDecoration( + border: Border(bottom: BorderSide(color: Colors.grey))), + child: Row( + children: [ + Text("$label: ", + style: const TextStyle(fontWeight: FontWeight.bold)), + Expanded(child: Text(value.toString())) + ], + ), + ); + + Widget _buildWifiApList(BuildContext context) => accessPoints.isEmpty + ? const Text("NO SCANNED RESULTS") + : ListView.builder( + itemCount: accessPoints.length, + itemBuilder: (context, i) { + final ap = accessPoints[i]; + final title = ap.ssid.isNotEmpty ? ap.ssid : "**EMPTY**"; + final signalIcon = ap.level >= -80 + ? Icons.signal_wifi_4_bar + : Icons.signal_wifi_0_bar; + return ListTile( + visualDensity: VisualDensity.compact, + leading: Icon(signalIcon), + title: Text(title), + subtitle: Text(ap.capabilities), + onTap: () => showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text(title), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + _buildInfo("BSSDI", ap.bssid), + _buildInfo("Capability", ap.capabilities), + _buildInfo("frequency", "${ap.frequency}MHz"), + _buildInfo("level", ap.level), + _buildInfo("standard", ap.standard), + _buildInfo( + "centerFrequency0", "${ap.centerFrequency0}MHz"), + _buildInfo( + "centerFrequency1", "${ap.centerFrequency1}MHz"), + _buildInfo("channelWidth", ap.channelWidth), + _buildInfo("isPasspoint", ap.isPasspoint), + _buildInfo( + "operatorFriendlyName", ap.operatorFriendlyName), + _buildInfo("venueName", ap.venueName), + _buildInfo("is80211mcResponder", ap.is80211mcResponder), + ], + ), + ), + ), + ); + }, + ); + + Widget _buildWifiAPStreamable(BuildContext context) => !shouldStream + ? _buildWifiApList(context) + : FutureBuilder( + future: _canGetScannedResults(context), + builder: (context, snapshotCan) { + if (snapshotCan.connectionState != ConnectionState.done) { + return const CircularProgressIndicator(); + } + // return without stream - if can't + if (!(snapshotCan.data ?? false)) return _buildWifiApList(context); + return StreamBuilder>( + stream: WiFiScan.instance.onScannedResultsAvailable, + builder: (context, snapshot) { + // update accesspoint if available + accessPoints = snapshot.data ?? accessPoints; + return _buildWifiApList(context); + }, + ); + }, + ); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Builder( + builder: (context) => Padding( + padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 20), + child: Column( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + ElevatedButton.icon( + icon: const Icon(Icons.refresh), + label: const Text('GET'), + onPressed: () async { + if (await _canGetScannedResults(context)) { + accessPoints = + await WiFiScan.instance.getScannedResults(); + setState(() {}); + } + }, + ), + ElevatedButton.icon( + icon: const Icon(Icons.perm_scan_wifi), + label: const Text('SCAN'), + onPressed: () => _startScan(context), + ), + ], + ), + const Divider(), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + _buildSwitch("SHOULD CHECK", shouldCheck, + (v) => setState(() => shouldCheck = v)), + _buildSwitch("STREAM", shouldStream, + (v) => setState(() => shouldStream = v)), + ], + ), + const Divider(), + Flexible( + child: Center( + child: _buildWifiAPStreamable(context), + ), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/packages/wifi_scan/example/pubspec.yaml b/packages/wifi_scan/example/pubspec.yaml new file mode 100644 index 00000000..22421ad9 --- /dev/null +++ b/packages/wifi_scan/example/pubspec.yaml @@ -0,0 +1,84 @@ +name: wifi_scan_example +description: Demonstrates how to use the wifi_scan plugin. + +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: ">=2.12.0 <3.0.0" + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + wifi_scan: + # When depending on this package from a real application you should use: + # wifi_scan: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^1.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/wifi_scan/example/test/widget_test.dart b/packages/wifi_scan/example/test/widget_test.dart new file mode 100644 index 00000000..206180ae --- /dev/null +++ b/packages/wifi_scan/example/test/widget_test.dart @@ -0,0 +1,27 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:wifi_scan_example/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => + widget is Text && widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +} diff --git a/packages/wifi_scan/ios/.gitignore b/packages/wifi_scan/ios/.gitignore new file mode 100644 index 00000000..0c885071 --- /dev/null +++ b/packages/wifi_scan/ios/.gitignore @@ -0,0 +1,38 @@ +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +.DS_Store +*.swp +profile + +DerivedData/ +build/ +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m + +.generated/ + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +/Flutter/Generated.xcconfig +/Flutter/ephemeral/ +/Flutter/flutter_export_environment.sh \ No newline at end of file diff --git a/packages/wifi_scan/ios/Assets/.gitkeep b/packages/wifi_scan/ios/Assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/packages/wifi_scan/ios/Classes/SwiftWifiScanPlugin.swift b/packages/wifi_scan/ios/Classes/SwiftWifiScanPlugin.swift new file mode 100644 index 00000000..b0412b39 --- /dev/null +++ b/packages/wifi_scan/ios/Classes/SwiftWifiScanPlugin.swift @@ -0,0 +1,45 @@ +import Flutter + +// Since no API for scanning or getting scanned results in iOS. +// This class is just a "dummy" implementation with sane returns. +// It is maintained to avoid `MissingPluginException`. +public class SwiftWifiScanPlugin: NSObject, FlutterPlugin { + public static func register(with registrar: FlutterPluginRegistrar) { + let instance = SwiftWifiScanPlugin() + // set Flutter channels - 1 for method, 1 for event + let channel = FlutterMethodChannel( + name: "wifi_scan", binaryMessenger: registrar.messenger() + ) + registrar.addMethodCallDelegate(instance, channel: channel) + let eventChannel = FlutterEventChannel( + name: "wifi_scan/onScannedResultsAvailable", + binaryMessenger: registrar.messenger() + ) + eventChannel.setStreamHandler(DummyStreamHandler()) + } + + public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { + switch(call.method){ + case "canStartScan": + return result(0) // not supported + case "startScan": + return result(false) // always fails + case "canGetScannedResults": + return result(0) // not supported + case "getScannedResults": + return result([]) // empty results + default: + return result(FlutterMethodNotImplemented) + } + } +} + + +class DummyStreamHandler: NSObject, FlutterStreamHandler{ + func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? { + return nil + } + func onCancel(withArguments arguments: Any?) -> FlutterError? { + return nil + } +} diff --git a/packages/wifi_scan/ios/Classes/WifiScanPlugin.h b/packages/wifi_scan/ios/Classes/WifiScanPlugin.h new file mode 100644 index 00000000..8e0a099e --- /dev/null +++ b/packages/wifi_scan/ios/Classes/WifiScanPlugin.h @@ -0,0 +1,4 @@ +#import + +@interface WifiScanPlugin : NSObject +@end diff --git a/packages/wifi_scan/ios/Classes/WifiScanPlugin.m b/packages/wifi_scan/ios/Classes/WifiScanPlugin.m new file mode 100644 index 00000000..e1819dce --- /dev/null +++ b/packages/wifi_scan/ios/Classes/WifiScanPlugin.m @@ -0,0 +1,15 @@ +#import "WifiScanPlugin.h" +#if __has_include() +#import +#else +// Support project import fallback if the generated compatibility header +// is not copied when this plugin is created as a library. +// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 +#import "wifi_scan-Swift.h" +#endif + +@implementation WifiScanPlugin ++ (void)registerWithRegistrar:(NSObject*)registrar { + [SwiftWifiScanPlugin registerWithRegistrar:registrar]; +} +@end diff --git a/packages/wifi_scan/ios/wifi_scan.podspec b/packages/wifi_scan/ios/wifi_scan.podspec new file mode 100644 index 00000000..9a0f3a73 --- /dev/null +++ b/packages/wifi_scan/ios/wifi_scan.podspec @@ -0,0 +1,23 @@ +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint wifi_scan.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'wifi_scan' + s.version = '0.0.1' + s.summary = 'Flutter plugin to scan for WiFi access points.' + s.description = <<-DESC +Flutter plugin to scan for WiFi access points. + DESC + s.homepage = 'https://wifi.flutternetwork.dev' + s.license = { :file => '../LICENSE' } + s.author = { 'WiFiFlutter' => 'contact@flutternetwork.dev' } + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' + s.dependency 'Flutter' + s.platform = :ios, '9.0' + + # Flutter.framework does not contain a i386 slice. + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } + s.swift_version = '5.0' +end diff --git a/packages/wifi_scan/lib/src/accesspoint.dart b/packages/wifi_scan/lib/src/accesspoint.dart new file mode 100644 index 00000000..777f1b72 --- /dev/null +++ b/packages/wifi_scan/lib/src/accesspoint.dart @@ -0,0 +1,165 @@ +part of '../wifi_scan.dart'; + +/// WiFi standards. +enum WiFiStandards { + /// Unknown. + unkown, + + /// Wi-Fi 802.11a/b/g. + legacy, + + /// Wi-Fi 802.11n (Wi-Fi 4). + n, + + /// Wi-Fi 802.11ac (Wi-Fi 5). + ac, + + /// Wi-Fi 802.11ax (Wi-Fi 6). + ax, + + /// Wi-Fi 802.11ad. + ad, +} + +WiFiStandards _deserializeWiFiStandards(int? standardCode) { + switch (standardCode) { + case 1: + return WiFiStandards.legacy; + case 4: + return WiFiStandards.n; + case 5: + return WiFiStandards.ac; + case 6: + return WiFiStandards.ax; + case 7: + return WiFiStandards.ad; + default: + return WiFiStandards.unkown; + } +} + +/// Channel bandwidth supported by WiFi. +enum WiFiChannelWidth { + /// Unknown. + unkown, + + /// 20 MHZ. + mhz20, + + /// 40 MHZ. + mhz40, + + /// 40 MHZ. + mhz80, + + /// 160 MHZ. + mhz160, + + /// 160 MHZ, but 80MHZ + 80MHZ. + mhz80Plus80, +} + +WiFiChannelWidth _deserializeWiFiChannelWidth(int? channelWidthCode) { + switch (channelWidthCode) { + case 0: + return WiFiChannelWidth.mhz20; + case 1: + return WiFiChannelWidth.mhz40; + case 2: + return WiFiChannelWidth.mhz80; + case 3: + return WiFiChannelWidth.mhz160; + case 4: + return WiFiChannelWidth.mhz80Plus80; + default: + return WiFiChannelWidth.unkown; + } +} + +/// Describes information about a detected access point. +class WiFiAccessPoint { + /// The network name. + final String ssid; + + /// The address of the access point. + final String bssid; + + /// Describes authentication and other schemes supported by the access point. + // TODO: parse this for proper enums for - security + final String capabilities; + + /// WiFi standard supported by the access poit. + final WiFiStandards standard; + + /// The detected signal strength in dBm, also known as the RSSI. + /// + /// The value is in negative integer, the greater the value, the stronger the + /// signal. The closer the value is to 0, the stronger the received signal + /// has been. + /// + /// Following data can be used to determine signal quality: + /// -30 dBm = Excellent + /// -67 dBm = Very Good + /// -70 dBm = Okay + /// -80 dBm = Not Good + /// -90 dBm = Unusable + /// For more info - https://www.securedgenetworks.com/blog/wifi-signal-strength. + // TODO: rename to rssi or signalStrength - and give additional enum for level + final int level; + + /// Channel bandwidth of the access point. + final WiFiChannelWidth? channelWidth; + + /// The primary 20MHz frequency of the channel over which the client is + /// communicating with the AP. + /// + /// The value is in MHz. + final int frequency; + + /// Center frequency of the access point. + /// + /// For [WiFiChannelWidth.mhz20] bandwidth, it is null. + /// For [WiFiChannelWidth.mhz80Plus80] bandwidth, it is the center frequency + /// of the first segment. + final int? centerFrequency0; + + /// Center frequency of the access point. + /// + /// Only used for [WiFiChannelWidth.mhz80Plus80] bandwidth, it is the center + /// frequency of the secod segment. + final int? centerFrequency1; + + /// Timestamp in microseconds (since boot) when this result was last seen. + final int? timestamp; + + /// Indicates if the access point is a Passpoint (Hotspot 2.0). + final bool? isPasspoint; + + /// Indicates Passpoint operator name published by access point. + final String? operatorFriendlyName; + + /// Indicates venue name published by access point. + /// + /// Only available on Passpoint network and if published by access point. + final String? venueName; + + /// Indicates if the access point can respond to IEEE 802.11mc (WiFi RTT) + /// ranging requests. + final bool? is80211mcResponder; + + WiFiAccessPoint._fromMap(Map map) + : ssid = map["ssid"], + bssid = map["bssid"], + capabilities = map["capabilities"], + frequency = map["frequency"], + level = map["level"], + timestamp = map["timestamp"], + standard = _deserializeWiFiStandards(map["standard"]), + centerFrequency0 = map["centerFrequency0"], + centerFrequency1 = map["centerFrequency1"], + channelWidth = _deserializeWiFiChannelWidth(map["channelWidth"]), + isPasspoint = map["isPasspoint"], + operatorFriendlyName = map["operatorFriendlyName"], + venueName = map["venueName"], + is80211mcResponder = map["is80211mcResponder"]; +} diff --git a/packages/wifi_scan/lib/src/can.dart b/packages/wifi_scan/lib/src/can.dart new file mode 100644 index 00000000..35917924 --- /dev/null +++ b/packages/wifi_scan/lib/src/can.dart @@ -0,0 +1,92 @@ +part of '../wifi_scan.dart'; + +/// Result for [WiFiScan.canStartScan] method. +enum CanStartScan { + /// Functionality is not supported. + notSupported, + + /// It is ok to call functionality. + yes, + + /// Location permission is required. + /// + /// A prompt for permission can be requested. + noLocationPermissionRequired, + + /// Location permission is denied. + /// + /// Need to ask user to manually allow from settings. + noLocationPermissionDenied, + + /// Location permission accuracy needs to be upgraded. + /// + /// Need to ask user to manually allow from settings. + noLocationPermissionUpgradeAccuracy, + + /// Location service needs to be enabled. + noLocationServiceDisabled, +} + +CanStartScan _deserializeCanStartScan(int? canCode) { + switch (canCode) { + case 0: + return CanStartScan.notSupported; + case 1: + return CanStartScan.yes; + case 2: + return CanStartScan.noLocationPermissionRequired; + case 3: + return CanStartScan.noLocationPermissionDenied; + case 4: + return CanStartScan.noLocationPermissionUpgradeAccuracy; + case 5: + return CanStartScan.noLocationServiceDisabled; + } + throw UnsupportedError("$canCode cannot be serialized to CanStartScan"); +} + +/// Result for [WiFiScan.canGetScannedResults] method. +enum CanGetScannedResults { + /// Functionality is not supported. + notSupported, + + /// It is ok to call functionality. + yes, + + /// Location permission is required. + /// + /// A prompt for permission can be requested. + noLocationPermissionRequired, + + /// Location permission is denied. + /// + /// Need to ask user to manually allow from settings. + noLocationPermissionDenied, + + /// Location permission accuracy needs to be upgraded. + /// + /// Need to ask user to manually allow from settings. + noLocationPermissionUpgradeAccuracy, + + /// Location service needs to be enabled. + noLocationServiceDisabled, +} + +CanGetScannedResults _deserializeCanGetScannedResults(int? canCode) { + switch (canCode) { + case 0: + return CanGetScannedResults.notSupported; + case 1: + return CanGetScannedResults.yes; + case 2: + return CanGetScannedResults.noLocationPermissionRequired; + case 3: + return CanGetScannedResults.noLocationPermissionDenied; + case 4: + return CanGetScannedResults.noLocationPermissionUpgradeAccuracy; + case 5: + return CanGetScannedResults.noLocationServiceDisabled; + } + throw UnsupportedError( + "$canCode cannot be serialized to CanGetScannedNetworks"); +} diff --git a/packages/wifi_scan/lib/wifi_scan.dart b/packages/wifi_scan/lib/wifi_scan.dart new file mode 100644 index 00000000..205d7df4 --- /dev/null +++ b/packages/wifi_scan/lib/wifi_scan.dart @@ -0,0 +1,90 @@ +import 'dart:async'; + +import 'package:flutter/services.dart'; + +part 'src/accesspoint.dart'; + +part 'src/can.dart'; + +/// The `wifi_scan` plugin entry point. +/// +/// To get a new instance, call [WiFiScan.instance]. +class WiFiScan { + WiFiScan._(); + + /// Singleton instance of [WiFiScan]. + static final instance = WiFiScan._(); + + final _channel = const MethodChannel('wifi_scan'); + final _scannedResultsAvailableChannel = + const EventChannel('wifi_scan/onScannedResultsAvailable'); + Stream>? _onScannedResultsAvailable; + + /// Checks if it is ok to invoke [startScan]. + /// + /// Necesearry platform requirements, like permissions dependent services, + /// configuration, etc are checked. + /// + /// Set [askPermissions] flag to ask user for necessary permissions. + Future canStartScan({bool askPermissions = true}) async { + final canCode = await _channel.invokeMethod("canStartScan", { + "askPermissions": askPermissions, + }); + return _deserializeCanStartScan(canCode); + } + + /// Request a Wi-Fi scan. + /// + /// Return value indicates if the "scan" is being triggered. + /// + /// Should call [canStartScan] as a check before calling this method. + Future startScan() async { + final isSucess = await _channel.invokeMethod("startScan"); + return isSucess!; + } + + /// Checks if it is ok to invoke [getScannedResults] or [onScannedResultsAvailable]. + /// + /// Necesearry platform requirements, like permissions dependent services, + /// configuration, etc are checked. + /// + /// Set [askPermissions] flag to ask user for necessary permissions. + Future canGetScannedResults( + {bool askPermissions = true}) async { + final canCode = await _channel.invokeMethod("canGetScannedResults", { + "askPermissions": askPermissions, + }); + return _deserializeCanGetScannedResults(canCode); + } + + /// Get scanned access point. + /// + /// This are cached accesss points from most recently performed scan. + /// + /// Should call [canGetScannedResults] as a check before calling this method. + Future> getScannedResults() async { + final scannedResults = + await _channel.invokeListMethod("getScannedResults"); + return scannedResults! + .map((map) => WiFiAccessPoint._fromMap(map)) + .toList(growable: false); + } + + /// Fires whenever new scanned results are available. + /// + /// New results are added to stream when platform performs the scan, either by + /// itself or trigger with [startScan]. + /// + /// Should call [canGetScannedResults] as a check before calling this method. + Stream> get onScannedResultsAvailable => + _onScannedResultsAvailable ??= + _scannedResultsAvailableChannel.receiveBroadcastStream().map((event) { + if (event is Error) throw event; + if (event is List) { + return event + .map((map) => WiFiAccessPoint._fromMap(map)) + .toList(growable: false); + } + return const []; + }); +} diff --git a/packages/wifi_scan/pubspec.yaml b/packages/wifi_scan/pubspec.yaml new file mode 100644 index 00000000..530cb752 --- /dev/null +++ b/packages/wifi_scan/pubspec.yaml @@ -0,0 +1,65 @@ +name: wifi_scan +description: Flutter plugin to scan for WiFi access points. +version: 0.0.1 +homepage: https://github.com/alternadom/WiFiFlutter/tree/master/packages/wifi_scan + +environment: + sdk: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^1.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' and Android 'package' identifiers should not ordinarily + # be modified. They are used by the tooling to maintain consistency when + # adding or updating assets for this project. + plugin: + platforms: + android: + package: dev.flutternetwork.wifi.wifi_scan + pluginClass: WifiScanPlugin + ios: + pluginClass: WifiScanPlugin + + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages diff --git a/packages/wifi_scan/test/wifi_scan_test.dart b/packages/wifi_scan/test/wifi_scan_test.dart new file mode 100644 index 00000000..9f84ec28 --- /dev/null +++ b/packages/wifi_scan/test/wifi_scan_test.dart @@ -0,0 +1,103 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:wifi_scan/wifi_scan.dart'; + +void main() { + const channel = MethodChannel('wifi_scan'); + final mockHandlers = {}; + + TestWidgetsFlutterBinding.ensureInitialized(); + + setUp(() { + TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger + .setMockMethodCallHandler(channel, (call) { + final result = mockHandlers[call.method]?.call(call.arguments); + if (result is Future) return result; + return Future.value(result); + }); + }); + + tearDown(() { + mockHandlers.clear(); + channel.setMockMethodCallHandler(null); + }); + + test('canStartScan', () async { + final canCodes = [0, 1, 2, 3, 4, 5]; + final enumValues = [ + CanStartScan.notSupported, + CanStartScan.yes, + CanStartScan.noLocationPermissionRequired, + CanStartScan.noLocationPermissionDenied, + CanStartScan.noLocationPermissionUpgradeAccuracy, + CanStartScan.noLocationServiceDisabled, + ]; + for (int i = 0; i < canCodes.length; i++) { + mockHandlers["canStartScan"] = (_) => canCodes[i]; + expect(await WiFiScan.instance.canStartScan(), enumValues[i]); + } + + // -ve test + final badCanCodes = [null, -1, 6, 7]; + for (int i = 0; i < badCanCodes.length; i++) { + mockHandlers["canStartScan"] = (_) => badCanCodes[i]; + expect(() async => await WiFiScan.instance.canStartScan(), + throwsUnsupportedError); + } + }); + + test('startScan', () async { + mockHandlers["startScan"] = (_) => true; + expect(await WiFiScan.instance.startScan(), true); + }); + + test("CanGetScannedResults", () async { + final canCodes = [0, 1, 2, 3, 4, 5]; + final enumValues = [ + CanGetScannedResults.notSupported, + CanGetScannedResults.yes, + CanGetScannedResults.noLocationPermissionRequired, + CanGetScannedResults.noLocationPermissionDenied, + CanGetScannedResults.noLocationPermissionUpgradeAccuracy, + CanGetScannedResults.noLocationServiceDisabled, + ]; + for (int i = 0; i < canCodes.length; i++) { + mockHandlers["canGetScannedResults"] = (_) => canCodes[i]; + expect(await WiFiScan.instance.canGetScannedResults(), enumValues[i]); + } + + // -ve test + final badCanCodes = [null, -1, 6, 7]; + for (int i = 0; i < badCanCodes.length; i++) { + mockHandlers["canGetScannedResults"] = (_) => badCanCodes[i]; + expect(() async => await WiFiScan.instance.canGetScannedResults(), + throwsUnsupportedError); + } + }); + + test("getScannedResults", () async { + mockHandlers["getScannedResults"] = (_) => [ + { + "ssid": "my-ssid", + "bssid": "00:00:00:12", + "capabilities": "Unknown", + "frequency": 600, + "level": 5, + "timestamp": null, + "standard": null, + "centerFrequency0": null, + "centerFrequency1": null, + "channelWidth": null, + "isPasspoint": null, + "operatorFriendlyName": null, + "venueName": null, + "is80211mcResponder": null, + } + ]; + final scannedNetworks = await WiFiScan.instance.getScannedResults(); + expect(scannedNetworks.length, 1); + }); + + // TODO: firgure out way to mock EventChannel + // test("onScannedResultsAvailable", () async {}); +}