Configure App to use MachineLearningController
This commit is contained in:
parent
b87e40429f
commit
bbb1caa313
3 changed files with 23 additions and 19 deletions
|
@ -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();
|
||||
},
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue