π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix: add more things for testing
Prateek Sunalecf58c175b99
diff --git a/mobile/apps/photos/ios/Podfile.lock b/mobile/apps/photos/ios/Podfile.lockindex 785d7a3a52..b1987b8081 100644--- a/mobile/apps/photos/ios/Podfile.lock+++ b/mobile/apps/photos/ios/Podfile.lock@@ -12,6 +12,8 @@ PODS:- Flutter- device_info_plus (0.0.1):- Flutter+ - emoji_picker_flutter (0.0.1):+ - Flutter- ffmpeg_kit_custom (6.0.3)- ffmpeg_kit_flutter (6.0.3):- ffmpeg_kit_custom@@ -228,6 +230,8 @@ PODS:- Flutter- url_launcher_ios (0.0.1):- Flutter+ - vibration (1.7.5):+ - Flutter- video_player_avfoundation (0.0.1):- Flutter- FlutterMacOS@@ -248,6 +252,7 @@ DEPENDENCIES:- cupertino_http (from `.symlinks/plugins/cupertino_http/darwin`)- dart_ui_isolate (from `.symlinks/plugins/dart_ui_isolate/ios`)- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)+ - emoji_picker_flutter (from `.symlinks/plugins/emoji_picker_flutter/ios`)- ffmpeg_kit_flutter (from `.symlinks/plugins/ffmpeg_kit_flutter/ios`)- file_saver (from `.symlinks/plugins/file_saver/ios`)- firebase_core (from `.symlinks/plugins/firebase_core/ios`)@@ -293,6 +298,7 @@ DEPENDENCIES:- thermal (from `.symlinks/plugins/thermal/ios`)- ua_client_hints (from `.symlinks/plugins/ua_client_hints/ios`)- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)+ - vibration (from `.symlinks/plugins/vibration/ios`)- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)- video_thumbnail (from `.symlinks/plugins/video_thumbnail/ios`)- volume_controller (from `.symlinks/plugins/volume_controller/ios`)@@ -335,6 +341,8 @@ EXTERNAL SOURCES::path: ".symlinks/plugins/dart_ui_isolate/ios"device_info_plus::path: ".symlinks/plugins/device_info_plus/ios"+ emoji_picker_flutter:+ :path: ".symlinks/plugins/emoji_picker_flutter/ios"ffmpeg_kit_flutter::path: ".symlinks/plugins/ffmpeg_kit_flutter/ios"file_saver:@@ -425,6 +433,8 @@ EXTERNAL SOURCES::path: ".symlinks/plugins/ua_client_hints/ios"url_launcher_ios::path: ".symlinks/plugins/url_launcher_ios/ios"+ vibration:+ :path: ".symlinks/plugins/vibration/ios"video_player_avfoundation::path: ".symlinks/plugins/video_player_avfoundation/darwin"video_thumbnail:@@ -443,6 +453,7 @@ SPEC CHECKSUMS:cupertino_http: 94ac07f5ff090b8effa6c5e2c47871d48ab7c86cdart_ui_isolate: 46f6714abe6891313267153ef6f9748d8ecfcab1device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe+ emoji_picker_flutter: ed468d9746c21711e66b2788880519a9de5de211ffmpeg_kit_custom: 682b4f2f1ff1f8abae5a92f6c3540f2441d5be99ffmpeg_kit_flutter: 915b345acc97d4142e8a9a8549d177ff10f043f5file_saver: 6cdbcddd690cb02b0c1a0c225b37cd805c2bf8b6@@ -507,6 +518,7 @@ SPEC CHECKSUMS:thermal: d4c48be750d1ddbab36b0e2dcb2471531bc8df41ua_client_hints: 92fe0d139619b73ec9fcb46cc7e079a26178f586url_launcher_ios: 694010445543906933d732453a59da0a173ae33d+ vibration: 8e2f50fc35bb736f9eecb7dd9f7047fbb6a6e888video_player_avfoundation: 2cef49524dd1f16c5300b9cd6efd9611ce03639bvideo_thumbnail: b637e0ad5f588ca9945f6e2c927f73a69a661140volume_controller: 3657a1f65bedb98fa41ff7dc5793537919f31b12diff --git a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxprojindex 46e7b2624c..6c37a7fc87 100644--- a/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj+++ b/mobile/apps/photos/ios/Runner.xcodeproj/project.pbxproj@@ -532,6 +532,7 @@"${BUILT_PRODUCTS_DIR}/cupertino_http/cupertino_http.framework","${BUILT_PRODUCTS_DIR}/dart_ui_isolate/dart_ui_isolate.framework","${BUILT_PRODUCTS_DIR}/device_info_plus/device_info_plus.framework",+ "${BUILT_PRODUCTS_DIR}/emoji_picker_flutter/emoji_picker_flutter.framework","${BUILT_PRODUCTS_DIR}/file_saver/file_saver.framework","${BUILT_PRODUCTS_DIR}/flutter_email_sender/flutter_email_sender.framework","${BUILT_PRODUCTS_DIR}/flutter_image_compress_common/flutter_image_compress_common.framework",@@ -574,6 +575,7 @@"${BUILT_PRODUCTS_DIR}/thermal/thermal.framework","${BUILT_PRODUCTS_DIR}/ua_client_hints/ua_client_hints.framework","${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework",+ "${BUILT_PRODUCTS_DIR}/vibration/vibration.framework","${BUILT_PRODUCTS_DIR}/video_player_avfoundation/video_player_avfoundation.framework","${BUILT_PRODUCTS_DIR}/video_thumbnail/video_thumbnail.framework","${BUILT_PRODUCTS_DIR}/volume_controller/volume_controller.framework",@@ -626,6 +628,7 @@"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/cupertino_http.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/dart_ui_isolate.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info_plus.framework",+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/emoji_picker_flutter.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/file_saver.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_email_sender.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_image_compress_common.framework",@@ -668,6 +671,7 @@"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/thermal.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ua_client_hints.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework",+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/vibration.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_player_avfoundation.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/video_thumbnail.framework","${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/volume_controller.framework",diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dartindex e7e24e2ffc..428dd4dc74 100644--- a/mobile/apps/photos/lib/main.dart+++ b/mobile/apps/photos/lib/main.dart@@ -184,10 +184,13 @@ Future<void> _runMinimally(String taskId, TimeLogger tlog) async {// only runs for androidawait _homeWidgetSync(true);- // await MLService.instance.init();- // await PersonService.init(entityService, MLDataDB.instance, prefs);- // await MLService.instance.runAllML(force: true);- await smartAlbumsService.syncSmartAlbums();+ 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 smartAlbumsService.syncSmartAlbums();+ }}Future<void> _init(bool isBackground, {String via = ''}) async {diff --git a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dartindex dfc663f85c..ec8787eaaf 100644--- a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart+++ b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart@@ -8,6 +8,7 @@ import "package:flutter/foundation.dart";import "package:logging/logging.dart";import "package:photos/core/event_bus.dart";import "package:photos/events/compute_control_event.dart";+import "package:photos/main.dart";import "package:thermal/thermal.dart";enum _ComputeRunState {@@ -42,6 +43,13 @@ class ComputeController {ComputeController() {_logger.info('ComputeController constructor');++ // we don't need listeners to be initialized in background+ if (isProcessBg) {+ _logger.info('init done ');+ return;+ }+_startInteractionTimer(kDefaultInteractionTimeout);if (Platform.isIOS) {if (kDebugMode) {@@ -71,6 +79,8 @@ class ComputeController {}bool requestCompute({bool ml = false, bool stream = false}) {+ // TODO: Remove after testing+ return false;_logger.info("Requesting compute: ml: $ml, stream: $stream");if (!_isDeviceHealthy || !_canRunGivenUserInteraction()) {_logger.info("Device not healthy or user interacting, denying request.");@@ -175,6 +185,25 @@ class ComputeController {_startInteractionTimer(kDefaultInteractionTimeout);}+ Future<bool> isDeviceHealthyFuture() async {+ if (!isProcessBg) return isDeviceHealthy;++ // Update Thermal status+ _lastThermalStatus = await _thermal.thermalStatus;++ // Update Battery info and device health+ if (Platform.isIOS) {+ _iosLastBatteryInfo = await BatteryInfoPlugin().iosBatteryInfo;+ _isDeviceHealthy = _computeIsiOSDeviceHealthy();+ } else {+ _androidLastBatteryInfo = await BatteryInfoPlugin().androidBatteryInfo;+ _isDeviceHealthy = _computeIsAndroidDeviceHealthy();+ }++ _logger.info("Device health status: $_isDeviceHealthy");+ return _isDeviceHealthy;+ }+void _onAndroidBatteryStateUpdate(AndroidBatteryInfo? batteryInfo) {_androidLastBatteryInfo = batteryInfo;_logger.info("Battery info: ${batteryInfo!.toJson()}");diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart b/mobile/apps/photos/lib/services/machine_learning/ml_service.dartindex 5425f3160a..31942fbe59 100644--- a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart+++ b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart@@ -10,6 +10,7 @@ import "package:photos/db/files_db.dart";import "package:photos/db/ml/db.dart";import "package:photos/events/compute_control_event.dart";import "package:photos/events/people_changed_event.dart";+import "package:photos/main.dart";import "package:photos/models/ml/face/face.dart";import "package:photos/models/ml/ml_versions.dart";import "package:photos/service_locator.dart";@@ -69,31 +70,36 @@ class MLService {_logger.info("client: $client");// Listen on ComputeController- Bus.instance.on<ComputeControlEvent>().listen((event) {- if (!flagService.hasGrantedMLConsent) {- return;- }+ /// 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 (!flagService.hasGrantedMLConsent) {+ return;+ }- _mlControllerStatus = event.shouldRun;- if (_mlControllerStatus) {- if (_shouldPauseIndexingAndClustering) {- _cancelPauseIndexingAndClustering();- _logger.info(- "MLController allowed running ML, faces indexing undoing previous pause",- );+ _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());} else {_logger.info(- "MLController allowed running ML, faces indexing starting",+ "MLController stopped running ML, faces indexing will be paused (unless it's fetching embeddings)",);+ pauseIndexingAndClustering();}- unawaited(runAllML());- } else {- _logger.info(- "MLController stopped running ML, faces indexing will be paused (unless it's fetching embeddings)",- );- pauseIndexingAndClustering();- }- });+ });+ }_isInitialized = true;_logger.info('init done');@@ -136,7 +142,7 @@ class MLService {);await clusterAllImages();}- if (_mlControllerStatus == true) {+ if (!isProcessBg && _mlControllerStatus == true) {// refresh discover sectionmagicCacheService.updateCache(forced: force).ignore();// refresh memories section@@ -148,7 +154,7 @@ class MLService {if ((await mlDataDB.getUnclusteredFaceCount()) > 0) {await clusterAllImages();}- if (_mlControllerStatus == true) {+ if (!isProcessBg && _mlControllerStatus == true) {// refresh discover sectionmagicCacheService.updateCache().ignore();// refresh memories section (only runs if forced is true)@@ -160,8 +166,10 @@ class MLService {} finally {_logger.severe("ML finished running");_isRunningML = false;- computeController.releaseCompute(ml: true);- VideoPreviewService.instance.queueFiles();+ if (!isProcessBg) {+ computeController.releaseCompute(ml: true);+ VideoPreviewService.instance.queueFiles();+ }}}diff --git a/mobile/apps/photos/lib/utils/bg_task_utils.dart b/mobile/apps/photos/lib/utils/bg_task_utils.dartindex 1ae1dfcb0b..1218607137 100644--- a/mobile/apps/photos/lib/utils/bg_task_utils.dart+++ b/mobile/apps/photos/lib/utils/bg_task_utils.dart@@ -23,7 +23,8 @@ void callbackDispatcher() {try {BgTaskUtils.$.info('Task started $tlog');await runBackgroundTask(taskName, tlog).timeout(- Platform.isIOS ? kBGTaskTimeout : const Duration(hours: 1),+ // TODO: For testing don't do seppuku+ Platform.isIOS && false ? kBGTaskTimeout : const Duration(hours: 1),onTimeout: () async {BgTaskUtils.$.warning("TLE, committing seppuku for taskID: $taskName",diff --git a/mobile/apps/photos/lib/utils/isolate/super_isolate.dart b/mobile/apps/photos/lib/utils/isolate/super_isolate.dartindex 603bd1ef15..f1bae4dfaf 100644--- a/mobile/apps/photos/lib/utils/isolate/super_isolate.dart+++ b/mobile/apps/photos/lib/utils/isolate/super_isolate.dart@@ -145,8 +145,14 @@ abstract class SuperIsolate {final exception = Exception(errorMessage);final stackTrace = StackTrace.fromString(errorStackTrace);completer.completeError(exception, stackTrace);+ logger.warning(+ "operation ${operation.name}, completed with warnings",+ errorMessage,+ errorStackTrace,+ );} else {completer.complete(data);+ logger.info("operation ${operation.name}, completed successfully");}});_activeTasks--;