π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Put faces timeline behind internal flag
laurenspriemce5d83de04af
diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dartindex fb96bbbeda..d057e5b61b 100644--- a/mobile/apps/photos/lib/main.dart+++ b/mobile/apps/photos/lib/main.dart@@ -314,9 +314,13 @@ Future<void> _init(bool isBackground, {String via = ''}) async {unawaited(MLService.instance.init());await PersonService.init(entityService, MLDataDB.instance, preferences);await FacesTimelineService.instance.init();- FacesTimelineService.instance- .queueFullRecompute(force: true, trigger: "startup")- .ignore();+ if (flagService.facesTimeline) {+ FacesTimelineService.instance+ .queueFullRecompute(force: true, trigger: "startup")+ .ignore();+ } else {+ _logger.info("Faces timeline disabled via feature flag");+ }EnteWakeLockService.instance.init(preferences);logLocalSettings();initComplete = true;diff --git a/mobile/apps/photos/lib/services/faces_timeline/faces_timeline_service.dart b/mobile/apps/photos/lib/services/faces_timeline/faces_timeline_service.dartindex 9120ef393b..3d63a56d86 100644--- a/mobile/apps/photos/lib/services/faces_timeline/faces_timeline_service.dart+++ b/mobile/apps/photos/lib/services/faces_timeline/faces_timeline_service.dart@@ -13,6 +13,7 @@ import "package:photos/models/faces_timeline/faces_timeline_models.dart";import "package:photos/models/file/file.dart";import "package:photos/models/ml/face/face.dart";import "package:photos/models/ml/face/person.dart";+import "package:photos/service_locator.dart";import "package:photos/services/faces_timeline/faces_timeline_cache_service.dart";import "package:photos/services/machine_learning/face_ml/person/person_service.dart";import "package:photos/services/machine_learning/ml_result.dart";@@ -55,6 +56,8 @@ class FacesTimelineService {StreamSubscription<PeopleChangedEvent>? _peopleChangedSubscription;+ bool get isFeatureEnabled => flagService.facesTimeline;+Future<void> init() async {if (_initialized) return;await _cacheService.init();@@ -74,6 +77,12 @@ class FacesTimelineService {bool force = false,String trigger = "",}) async {+ if (!isFeatureEnabled) {+ _logger.fine(+ "Faces timeline full recompute skipped ($trigger): feature disabled",+ );+ return;+ }if (!PersonService.isInitialized) {_logger.warning("Faces timeline full recompute skipped: PersonService not initialized",@@ -99,6 +108,12 @@ class FacesTimelineService {bool force = false,String trigger = "",}) {+ if (!isFeatureEnabled) {+ _logger.fine(+ "Faces timeline recompute skipped for $personId ($trigger): feature disabled",+ );+ return;+ }if (personId.isEmpty) return;_precomputeQueue.addTask(personId, () async {await _recomputeTimelineForPerson(@@ -110,14 +125,19 @@ class FacesTimelineService {}Future<FacesTimelinePersonTimeline?> getTimeline(String personId) {+ if (!isFeatureEnabled) return Future.value(null);return _cacheService.getTimeline(personId);}bool hasReadyTimelineSync(String personId) {+ if (!isFeatureEnabled) {+ return false;+ }return readyPersonIds.value.contains(personId);}Future<bool> hasReadyTimeline(String personId) async {+ if (!isFeatureEnabled) return false;final timeline = await _cacheService.getTimeline(personId);return timeline?.isReady ?? false;}@@ -134,6 +154,12 @@ class FacesTimelineService {}void _handlePeopleChange(PeopleChangedEvent event) {+ if (!isFeatureEnabled) {+ _logger.fine(+ "Faces timeline people change ignored (${event.type.name}): feature disabled",+ );+ return;+ }final personId = event.person?.remoteID;switch (event.type) {case PeopleEventType.saveOrEditPerson:@@ -169,6 +195,12 @@ class FacesTimelineService {required bool force,required String trigger,}) async {+ if (!isFeatureEnabled) {+ _logger.fine(+ "Faces timeline compute skipped for $personId ($trigger): feature disabled",+ );+ return;+ }if (!PersonService.isInitialized) {_logger.warning("Faces timeline recompute skipped for $personId: PersonService not initialized",diff --git a/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_debug_panel.dart b/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_debug_panel.dartindex ed3f93cfa9..9a03ecdd44 100644--- a/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_debug_panel.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_debug_panel.dart@@ -6,6 +6,7 @@ import "package:photos/core/event_bus.dart";import "package:photos/events/faces_timeline_changed_event.dart";import "package:photos/models/faces_timeline/faces_timeline_models.dart";import "package:photos/models/ml/face/person.dart";+import "package:photos/service_locator.dart";import "package:photos/services/faces_timeline/faces_timeline_cache_service.dart";import "package:photos/services/faces_timeline/faces_timeline_service.dart";import "package:photos/theme/ente_theme.dart";@@ -27,10 +28,12 @@ class _FacesTimelineDebugPanelState extends State<FacesTimelineDebugPanel> {String? _info;StreamSubscription<FacesTimelineChangedEvent>? _timelineSubscription;+ bool get _featureEnabled => flagService.facesTimeline;+@overridevoid initState() {super.initState();- if (kDebugMode) {+ if (kDebugMode && _featureEnabled) {_reloadTimeline();_timelineSubscription = Bus.instance.on<FacesTimelineChangedEvent>()@@ -119,7 +122,7 @@ class _FacesTimelineDebugPanelState extends State<FacesTimelineDebugPanel> {@overrideWidget build(BuildContext context) {- if (!kDebugMode) return const SizedBox.shrink();+ if (!kDebugMode || !_featureEnabled) return const SizedBox.shrink();final colorScheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);final timeline = _timeline;diff --git a/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_page.dart b/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_page.dartindex 30abedfb94..a51ef13413 100644--- a/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/faces_timeline_page.dart@@ -85,6 +85,7 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>double _currentCaptionValue = 0;_CaptionType _currentCaptionType = _CaptionType.yearsAgo;int _maxCaptionDigits = 1;+ bool get _featureEnabled => flagService.facesTimeline;@overridevoid initState() {@@ -96,7 +97,11 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>..addListener(_onCardAnimationTick)..addStatusListener(_onCardAnimationStatusChanged);_stackProgressNotifier = ValueNotifier<double>(_stackProgress);- unawaited(_loadFrames());+ if (_featureEnabled) {+ unawaited(_loadFrames());+ } else {+ _timelineUnavailable = true;+ }}@override@@ -466,6 +471,21 @@ class _FacesTimelinePageState extends State<FacesTimelinePage>@overrideWidget build(BuildContext context) {+ if (!_featureEnabled) {+ final l10n = context.l10n;+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+ return Scaffold(+ appBar: AppBar(title: Text(l10n.facesTimelineAppBarTitle)),+ body: Center(+ child: Text(+ l10n.facesTimelineUnavailable,+ style: textTheme.body.copyWith(color: colorScheme.textBase),+ textAlign: TextAlign.center,+ ),+ ),+ );+ }return Theme(data: darkThemeData,child: Builder(diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart b/mobile/apps/photos/lib/ui/viewer/people/people_page.dartindex 43f1963c58..6382a40624 100644--- a/mobile/apps/photos/lib/ui/viewer/people/people_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/people_page.dart@@ -70,6 +70,8 @@ class _PeoplePageState extends State<PeoplePage> {ValueNotifier<Set<String>>? _timelineNotifier;VoidCallback? _timelineListener;+ bool get _facesTimelineEnabled => flagService.facesTimeline;+@overridevoid initState() {super.initState();@@ -107,17 +109,21 @@ class _PeoplePageState extends State<PeoplePage> {widget.searchResult!.getHierarchicalSearchFilter(),): null;- _timelineNotifier = FacesTimelineService.instance.readyPersonIds;- _timelineListener = () {- if (!mounted) return;- setState(() {});- };- _timelineNotifier!.addListener(_timelineListener!);- if (!FacesTimelineService.instance.hasReadyTimelineSync(_person.remoteID)) {- FacesTimelineService.instance.schedulePersonRecompute(+ if (_facesTimelineEnabled) {+ _timelineNotifier = FacesTimelineService.instance.readyPersonIds;+ _timelineListener = () {+ if (!mounted) return;+ setState(() {});+ };+ _timelineNotifier!.addListener(_timelineListener!);+ if (!FacesTimelineService.instance.hasReadyTimelineSync(_person.remoteID,- trigger: "people_page_visit",- );+ )) {+ FacesTimelineService.instance.schedulePersonRecompute(+ _person.remoteID,+ trigger: "people_page_visit",+ );+ }}}@@ -152,6 +158,7 @@ class _PeoplePageState extends State<PeoplePage> {}Future<void> _openFacesTimelinePage() async {+ if (!_facesTimelineEnabled) return;_timelineLogger.info("banner_tap person=${_person.remoteID}");await routeToPage(context, FacesTimelinePage(person: _person));if (!mounted) {@@ -163,12 +170,16 @@ class _PeoplePageState extends State<PeoplePage> {@overrideWidget build(BuildContext context) {_logger.info("Building for ${_person.data.name}");- final bool facesTimelineReady =- FacesTimelineService.instance.hasReadyTimelineSync(_person.remoteID);+ final bool featureEnabled = _facesTimelineEnabled;+ final bool facesTimelineReady = featureEnabled+ ? FacesTimelineService.instance.hasReadyTimelineSync(+ _person.remoteID,+ )+ : false;final bool hasSeenFacesTimeline =localSettings.hasSeenFacesTimeline(_person.remoteID);final bool showFacesTimelineBanner =- facesTimelineReady && !hasSeenFacesTimeline;+ featureEnabled && facesTimelineReady && !hasSeenFacesTimeline;return GalleryBoundariesProvider(child: GalleryFilesState(@@ -187,8 +198,9 @@ class _PeoplePageState extends State<PeoplePage> {_selectedFiles,_person,facesTimelineReady: facesTimelineReady,- onFacesTimelineTap:- facesTimelineReady ? _openFacesTimelinePage : null,+ onFacesTimelineTap: featureEnabled && facesTimelineReady+ ? _openFacesTimelinePage+ : null,),),body: FutureBuilder<List<EnteFile>>(@@ -221,12 +233,15 @@ class _PeoplePageState extends State<PeoplePage> {personFiles: personFiles,loadPersonFiles: loadPersonFiles,personEntity: _person,+ facesTimelineEnabled: featureEnabled,showTimelineBanner:showFacesTimelineBanner,- onTimelineTap: () =>- unawaited(- _openFacesTimelinePage(),- ),+ onTimelineTap: featureEnabled &&+ facesTimelineReady+ ? () => unawaited(+ _openFacesTimelinePage(),+ )+ : null,);},)@@ -236,10 +251,14 @@ class _PeoplePageState extends State<PeoplePage> {personFiles: personFiles,loadPersonFiles: loadPersonFiles,personEntity: _person,+ facesTimelineEnabled: featureEnabled,showTimelineBanner: showFacesTimelineBanner,- onTimelineTap: () => unawaited(- _openFacesTimelinePage(),- ),+ onTimelineTap: featureEnabled &&+ facesTimelineReady+ ? () => unawaited(+ _openFacesTimelinePage(),+ )+ : null,),FileSelectionOverlayBar(PeoplePage.overlayType,@@ -273,6 +292,7 @@ class _Gallery extends StatefulWidget {final List<EnteFile> personFiles;final Future<List<EnteFile>> Function() loadPersonFiles;final PersonEntity personEntity;+ final bool facesTimelineEnabled;final bool showTimelineBanner;final VoidCallback? onTimelineTap;@@ -282,6 +302,7 @@ class _Gallery extends StatefulWidget {required this.personFiles,required this.loadPersonFiles,required this.personEntity,+ required this.facesTimelineEnabled,this.showTimelineBanner = false,this.onTimelineTap,});@@ -348,11 +369,12 @@ class _GalleryState extends State<_Gallery> {),),FacesTimelineBannerSection(- showBanner: widget.showTimelineBanner,+ showBanner: widget.facesTimelineEnabled && widget.showTimelineBanner,person: widget.personEntity,- onTap: widget.onTimelineTap,+ onTap: widget.facesTimelineEnabled ? widget.onTimelineTap : null,),- FacesTimelineDebugPanel(person: widget.personEntity),+ if (widget.facesTimelineEnabled)+ FacesTimelineDebugPanel(person: widget.personEntity),!userDismissedPersonGallerySuggestion? Dismissible(key: const Key("personGallerySuggestion"),diff --git a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dartindex 1933aaf41b..38fc822802 100644--- a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart+++ b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart@@ -74,6 +74,8 @@ class FlagService {bool get useWidgetV2 => kDebugMode;+ bool get facesTimeline => internalUser;+bool hasSyncedAccountFlags() {return _prefs.containsKey("remote_flags");}