π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fixes
Prateek Sunal58973b84ba96
diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dartindex 8a2e560894..a8fbee5f91 100644--- a/mobile/apps/photos/lib/main.dart+++ b/mobile/apps/photos/lib/main.dart@@ -222,12 +222,10 @@ Future<void> _runMinimally(String taskId, TimeLogger tlog) async {await _homeWidgetSync(true);if (flagService.enableMLInBackground) {- final isDeviceHealthy = await computeController.isDeviceHealthyFuture();- if (isDeviceHealthy) {- await MLService.instance.init();- await PersonService.init(entityService, MLDataDB.instance, prefs);- await MLService.instance.runAllML(force: true);- }+ await MLService.instance.init();+ await PersonService.init(entityService, MLDataDB.instance, prefs);+ // Refresh health in background and emit ComputeControlEvent.+ await computeController.isDeviceHealthyFuture();}_logger.info("[BG TASK] smart albums sync");await smartAlbumsService.syncSmartAlbums();diff --git a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dartindex c5af13880a..a3dd36c291 100644--- a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart+++ b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart@@ -69,16 +69,18 @@ class ComputeController {// Directly assign the values + Attach listener for compute controllerFuture<void> init() async {- // we don't need listeners to be initialized in background- if (isProcessBg) return;+ if (!isProcessBg) {+ // Initialize interaction tracking before any await to avoid first-tap races.+ _startInteractionTimer(kDefaultInteractionTimeout);- // Initialize interaction tracking before any await to avoid first-tap races.- _startInteractionTimer(kDefaultInteractionTimeout);-- await setMLDebugInteractionOverride(- turnOn: _localSettings.runMLDuringInteractionOverride,- persist: false,- );+ await setMLDebugInteractionOverride(+ turnOn: _localSettings.runMLDuringInteractionOverride,+ persist: false,+ );+ } else {+ // In background there is no user interaction signal, keep this false.+ _isUserInteracting = false;+ }// Thermal related_onThermalStateUpdate(await _thermal.thermalStatus);@@ -295,12 +297,16 @@ class ComputeController {// Update Battery info and device healthif (Platform.isIOS) {_iosLastBatteryInfo = await BatteryInfoPlugin().iosBatteryInfo;- _isDeviceHealthy = _computeIsiOSDeviceHealthy();+ _setDeviceHealth(_computeIsiOSDeviceHealthy());} else {_androidLastBatteryInfo = await BatteryInfoPlugin().androidBatteryInfo;- _isDeviceHealthy = _computeIsAndroidDeviceHealthy();+ _setDeviceHealth(_computeIsAndroidDeviceHealthy());}+ // In background we need this call-site to be self-sufficient so MLService+ // listeners can react immediately without waiting on init races.+ _hasCompletedInitialHealthChecks = true;+ _fireControlEvent();_logger.info("Device health status: $_isDeviceHealthy");return _isDeviceHealthy;}diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart b/mobile/apps/photos/lib/services/machine_learning/ml_service.dartindex 0592d5e856..c1a3f183d5 100644--- a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart+++ b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart@@ -95,40 +95,35 @@ class MLService {client = "${packageInfo.packageName}/${packageInfo.version}";_logger.info("client: $client");- // Listen on ComputeController- /// Only listen for events when in foreground,- /// so we don't waste resources when the app is in background- /// and we just do things sequentially- if (!isProcessBg) {- Bus.instance.on<ComputeControlEvent>().listen((event) {- if (!hasGrantedMLConsent) {- if (event.shouldRun) {- VideoPreviewService.instance.queueFiles(duration: Duration.zero);- }- return;+ // Listen on ComputeController in both foreground and background.+ Bus.instance.on<ComputeControlEvent>().listen((event) {+ if (!hasGrantedMLConsent) {+ if (!isProcessBg && event.shouldRun) {+ VideoPreviewService.instance.queueFiles(duration: Duration.zero);}+ return;+ }- _mlControllerStatus = event.shouldRun;- if (_mlControllerStatus) {- if (_shouldPauseIndexingAndClustering) {- _cancelPauseIndexingAndClustering();- _logger.info(- "MLController allowed running ML, faces indexing undoing previous pause",- );- } else {- _logger.info(- "MLController allowed running ML, faces indexing starting",- );- }- unawaited(runAllML());+ _mlControllerStatus = event.shouldRun;+ if (_mlControllerStatus) {+ if (_shouldPauseIndexingAndClustering) {+ _cancelPauseIndexingAndClustering();+ _logger.info(+ "MLController allowed running ML, faces indexing undoing previous pause",+ );} else {_logger.info(- "MLController stopped running ML, faces indexing will be paused (unless it's fetching embeddings)",+ "MLController allowed running ML, faces indexing starting",);- pauseIndexingAndClustering();}- });- }+ unawaited(runAllML());+ } else {+ _logger.info(+ "MLController stopped running ML, faces indexing will be paused (unless it's fetching embeddings)",+ );+ pauseIndexingAndClustering();+ }+ });_isInitialized = true;unawaited(_maybePredownloadLocalModels());@@ -175,6 +170,7 @@ class MLService {}Future<void> runAllML({bool force = false}) async {+ if (!isProcessBg) return;try {final MLMode mode = isOfflineMode ? MLMode.offline : MLMode.online;final mlDataDB = _dbForMode(mode);@@ -266,6 +262,7 @@ class MLService {/// This function first fetches from remote and checks if the image has already been analyzed/// with the lastest faceMlVersion and stored on remote or local database. If so, it skips the image.Future<void> fetchAndIndexAllImages({required MLMode mode}) async {+ if (!isProcessBg) return;if (!_canRunMLFunction(function: "Indexing")) return;bool rustRuntimePrepared = false;