From 84cc08e56effa724b21b2ff184d2eec15c34ff86 Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 17 Jun 2024 09:28:08 +0700 Subject: [PATCH] remove request local network permission at home Signed-off-by: phuoc --- lib/screen/home/home_navigation_page.dart | 14 -------------- lib/service/configuration_service.dart | 15 --------------- lib/util/local_network_helper.dart | 21 --------------------- 3 files changed, 50 deletions(-) delete mode 100644 lib/util/local_network_helper.dart diff --git a/lib/screen/home/home_navigation_page.dart b/lib/screen/home/home_navigation_page.dart index 8a704289c..5c46659ff 100644 --- a/lib/screen/home/home_navigation_page.dart +++ b/lib/screen/home/home_navigation_page.dart @@ -6,7 +6,6 @@ // import 'dart:async'; -import 'dart:io'; import 'package:after_layout/after_layout.dart'; import 'package:autonomy_flutter/common/injector.dart'; @@ -45,7 +44,6 @@ import 'package:autonomy_flutter/util/au_icons.dart'; import 'package:autonomy_flutter/util/constants.dart'; import 'package:autonomy_flutter/util/dio_util.dart'; import 'package:autonomy_flutter/util/inapp_notifications.dart'; -import 'package:autonomy_flutter/util/local_network_helper.dart'; import 'package:autonomy_flutter/util/log.dart'; import 'package:autonomy_flutter/util/style.dart'; import 'package:autonomy_flutter/util/ui_helper.dart'; @@ -316,18 +314,6 @@ class HomeNavigationPageState extends State WidgetsBinding.instance.addObserver(this); _fgbgSubscription = FGBGEvents.stream.listen(_handleForeBackground); unawaited(_syncArtist()); - - unawaited(_requestLocalNetworkPermission()); - } - - Future _requestLocalNetworkPermission() async { - if (Platform.isIOS) { - final didRequest = _configurationService.didGetLocalNetworkPermission(); - if (!didRequest) { - final result = await LocalNetworkHelper.requestLocalNetworkPermission(); - await _configurationService.setDidGetLocalNetworkPermission(result); - } - } } Future _syncArtist() async { diff --git a/lib/service/configuration_service.dart b/lib/service/configuration_service.dart index c6223c669..1f3b6bf9b 100644 --- a/lib/service/configuration_service.dart +++ b/lib/service/configuration_service.dart @@ -29,10 +29,6 @@ import 'package:uuid/uuid.dart'; //ignore_for_file: constant_identifier_names abstract class ConfigurationService { - bool didGetLocalNetworkPermission(); - - Future setDidGetLocalNetworkPermission(bool value); - Future setRecordOwners(List owners, {bool override = false}); List getRecordOwners(); @@ -281,8 +277,6 @@ abstract class ConfigurationService { } class ConfigurationServiceImpl implements ConfigurationService { - static const String keyDidGetLocalNetWorkPermission = - 'did_get_local_network_permission'; static const String keyRecordOwners = 'yoko_ono_record_owners'; static const String KEY_HAS_MERCHANDISE_SUPPORT_INDEX_ID = 'has_merchandise_support'; @@ -1227,15 +1221,6 @@ class ConfigurationServiceImpl implements ConfigurationService { await _preferences.setStringList(keyRecordOwners, currentOwners.toList()); } } - - @override - bool didGetLocalNetworkPermission() => - _preferences.getBool(keyDidGetLocalNetWorkPermission) ?? false; - - @override - Future setDidGetLocalNetworkPermission(bool value) async { - await _preferences.setBool(keyDidGetLocalNetWorkPermission, value); - } } enum ConflictAction { diff --git a/lib/util/local_network_helper.dart b/lib/util/local_network_helper.dart deleted file mode 100644 index 5e3ae199e..000000000 --- a/lib/util/local_network_helper.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'dart:io'; - -import 'package:autonomy_flutter/util/log.dart'; -import 'package:network_info_plus/network_info_plus.dart'; - -class LocalNetworkHelper { - static Future requestLocalNetworkPermission() async { - bool isGranted = false; - try { - final wifiIp = await NetworkInfo().getWifiIP(); - log.info('[LocalNetworkHelper] wifiIp: $wifiIp'); - await Socket.connect(wifiIp, 80, - timeout: const Duration(milliseconds: 100)); - isGranted = true; - } catch (e) { - log.info('[LocalNetworkHelper] requestLocalNetworkPermission Error: $e'); - isGranted = false; - } - return isGranted; - } -}