[mob] Service locator for mlController
This commit is contained in:
committed by
Neeraj Gupta
parent
674b5a9899
commit
35941b7f72
@@ -13,6 +13,7 @@ import 'package:media_extension/media_extension_action_types.dart';
|
||||
import 'package:photos/ente_theme_data.dart';
|
||||
import "package:photos/generated/l10n.dart";
|
||||
import "package:photos/l10n/l10n.dart";
|
||||
import "package:photos/service_locator.dart";
|
||||
import 'package:photos/services/app_lifecycle_service.dart';
|
||||
import "package:photos/services/home_widget_service.dart";
|
||||
import "package:photos/services/machine_learning/machine_learning_controller.dart";
|
||||
@@ -96,7 +97,7 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {
|
||||
if (Platform.isAndroid || kDebugMode) {
|
||||
return Listener(
|
||||
onPointerDown: (event) {
|
||||
MachineLearningController.instance.onUserInteraction();
|
||||
machineLearningController.onUserInteraction();
|
||||
},
|
||||
child: AdaptiveTheme(
|
||||
light: lightThemeData,
|
||||
@@ -126,7 +127,7 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {
|
||||
} else {
|
||||
return Listener(
|
||||
onPointerDown: (event) {
|
||||
MachineLearningController.instance.onUserInteraction();
|
||||
machineLearningController.onUserInteraction();
|
||||
},
|
||||
child: MaterialApp(
|
||||
title: "ente",
|
||||
|
||||
@@ -282,8 +282,6 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
|
||||
}
|
||||
_logger.info("PushService/HomeWidget done $tlog");
|
||||
unawaited(SemanticSearchService.instance.init());
|
||||
MachineLearningController.instance.init();
|
||||
_logger.info("MachineLearningController done $tlog");
|
||||
unawaited(MLService.instance.init());
|
||||
PersonService.init(
|
||||
entityService,
|
||||
|
||||
@@ -7,6 +7,7 @@ import "package:photos/gateways/entity_gw.dart";
|
||||
import "package:photos/services/billing_service.dart";
|
||||
import "package:photos/services/entity_service.dart";
|
||||
import "package:photos/services/location_service.dart";
|
||||
import "package:photos/services/machine_learning/machine_learning_controller.dart";
|
||||
import "package:photos/services/magic_cache_service.dart";
|
||||
import "package:photos/services/storage_bonus_service.dart";
|
||||
import "package:photos/services/trash_sync_service.dart";
|
||||
@@ -123,3 +124,9 @@ BillingService get billingService {
|
||||
);
|
||||
return _billingService!;
|
||||
}
|
||||
|
||||
MachineLearningController? _machineLearningController;
|
||||
MachineLearningController get machineLearningController {
|
||||
_machineLearningController ??= MachineLearningController();
|
||||
return _machineLearningController!;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,6 @@ import "package:photos/events/machine_learning_control_event.dart";
|
||||
class MachineLearningController {
|
||||
MachineLearningController._privateConstructor();
|
||||
|
||||
static final MachineLearningController instance =
|
||||
MachineLearningController._privateConstructor();
|
||||
|
||||
final _logger = Logger("MachineLearningController");
|
||||
|
||||
static const kMaximumTemperature = 42; // 42 degree celsius
|
||||
@@ -29,8 +26,8 @@ class MachineLearningController {
|
||||
|
||||
bool get isDeviceHealthy => _isDeviceHealthy;
|
||||
|
||||
void init() {
|
||||
_logger.info('init called');
|
||||
MachineLearningController() {
|
||||
_logger.info('MachineLearningController constructor');
|
||||
_startInteractionTimer(kDefaultInteractionTimeout);
|
||||
if (Platform.isIOS) {
|
||||
BatteryInfoPlugin()
|
||||
|
||||
@@ -7,7 +7,6 @@ import "package:photos/l10n/l10n.dart";
|
||||
import "package:photos/service_locator.dart";
|
||||
import "package:photos/services/machine_learning/face_ml/face_detection/face_detection_service.dart";
|
||||
import "package:photos/services/machine_learning/face_ml/face_embedding/face_embedding_service.dart";
|
||||
import "package:photos/services/machine_learning/machine_learning_controller.dart";
|
||||
import "package:photos/services/machine_learning/ml_service.dart";
|
||||
import "package:photos/services/machine_learning/semantic_search/clip/clip_image_encoder.dart";
|
||||
import "package:photos/services/machine_learning/semantic_search/clip/clip_text_encoder.dart";
|
||||
@@ -52,7 +51,7 @@ class _MachineLearningSettingsPageState
|
||||
void initState() {
|
||||
super.initState();
|
||||
_wakeLock.enable();
|
||||
MachineLearningController.instance.forceOverrideML(turnOn: true);
|
||||
machineLearningController.forceOverrideML(turnOn: true);
|
||||
if (!MLService.instance.areModelsDownloaded) {
|
||||
_timer = Timer.periodic(const Duration(seconds: 10), (timer) {
|
||||
if (mounted) {
|
||||
@@ -69,7 +68,7 @@ class _MachineLearningSettingsPageState
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_wakeLock.disable();
|
||||
MachineLearningController.instance.forceOverrideML(turnOn: false);
|
||||
machineLearningController.forceOverrideML(turnOn: false);
|
||||
_timer?.cancel();
|
||||
_advancedOptionsTimer?.cancel();
|
||||
}
|
||||
@@ -424,7 +423,7 @@ class MLStatusWidgetState extends State<MLStatusWidget> {
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final bool isDeviceHealthy =
|
||||
MachineLearningController.instance.isDeviceHealthy;
|
||||
machineLearningController.isDeviceHealthy;
|
||||
final int indexedFiles = snapshot.data!.indexedItems;
|
||||
final int pendingFiles = snapshot.data!.pendingItems;
|
||||
final bool hasWifi = snapshot.data!.hasWifiEnabled!;
|
||||
|
||||
Reference in New Issue
Block a user