π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Configure App to use MachineLearningController
vishnukvmdbbb1caa31300
diff --git a/lib/app.dart b/lib/app.dartindex 96d4b041dc..7c3acae6da 100644--- a/lib/app.dart+++ b/lib/app.dart@@ -13,7 +13,7 @@ import 'package:photos/ente_theme_data.dart';import "package:photos/generated/l10n.dart";import "package:photos/l10n/l10n.dart";import 'package:photos/services/app_lifecycle_service.dart';-import 'package:photos/services/machine_learning/semantic_search/semantic_search_service.dart';+import "package:photos/services/machine_learning/machine_learning_controller.dart";import 'package:photos/services/sync_service.dart';import 'package:photos/ui/tabs/home_widget.dart';import "package:photos/ui/viewer/actions/file_viewer.dart";@@ -85,10 +85,10 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {if (Platform.isAndroid || kDebugMode) {_userInteractionTimer = Timer(timeout, () {debugPrint("user is not interacting with the app");- SemanticSearchService.instance.startIndexing();+ MachineLearningController.instance.onUserInteractionEvent(false);});} else {- SemanticSearchService.instance.startIndexing();+ MachineLearningController.instance.onUserInteractionEvent(false);}}@@ -97,7 +97,7 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {if (Platform.isAndroid || kDebugMode) {return Listener(onPointerDown: (event) {- SemanticSearchService.instance.pauseIndexing();+ MachineLearningController.instance.onUserInteractionEvent(true);debugPrint("user is interacting with the app");_resetTimer();},diff --git a/lib/services/machine_learning/machine_learning_controller.dart b/lib/services/machine_learning/machine_learning_controller.dartindex f2f51e2adb..79120e9e42 100644--- a/lib/services/machine_learning/machine_learning_controller.dart+++ b/lib/services/machine_learning/machine_learning_controller.dart@@ -33,6 +33,10 @@ class MachineLearningController {}}+ void onUserInteractionEvent(bool isUserInteracting) {+ Bus.instance.fire(MachineLearningControlEvent(!isUserInteracting));+ }+bool _shouldRunMachineLearning(AndroidBatteryInfo info) {if (info.chargingStatus == ChargingStatus.Charging ||info.chargingStatus == ChargingStatus.Full) {diff --git a/lib/services/machine_learning/semantic_search/semantic_search_service.dart b/lib/services/machine_learning/semantic_search/semantic_search_service.dartindex a002d1b928..80a1b2d910 100644--- a/lib/services/machine_learning/semantic_search/semantic_search_service.dart+++ b/lib/services/machine_learning/semantic_search/semantic_search_service.dart@@ -55,18 +55,6 @@ class SemanticSearchService {get hasInitialized => _hasInitialized;- void startIndexing() {- _logger.info("Start indexing");- _healthCheckCompleter.complete();- }-- void pauseIndexing() {- if (_healthCheckCompleter.isCompleted) {- _logger.info("Pausing indexing");- _healthCheckCompleter = Completer<void>();- }- }-Future<void> init({bool shouldSyncImmediately = false,bool isInBackground = false,@@ -117,13 +105,13 @@ class SemanticSearchService {}if (isInBackground) {// Do not block on user interactions- startIndexing();+ _startIndexing();}Bus.instance.on<MachineLearningControlEvent>().listen((event) {if (event.shouldRun) {- startIndexing();+ _startIndexing();} else {- pauseIndexing();+ _pauseIndexing();}});}@@ -384,6 +372,18 @@ class SemanticSearchService {return Model.onnxClip;}}++ void _startIndexing() {+ _logger.info("Start indexing");+ _healthCheckCompleter.complete();+ }++ void _pauseIndexing() {+ if (_healthCheckCompleter.isCompleted) {+ _logger.info("Pausing indexing");+ _healthCheckCompleter = Completer<void>();+ }+ }}List<QueryResult> computeBulkScore(Map args) {