Skip to content

Commit aef28e3

Browse files
author
danny
committed
lib-updates
update location report to new Apple format
1 parent d8d0e24 commit aef28e3

6 files changed

Lines changed: 12 additions & 26 deletions

File tree

macless_haystack/lib/accessory/accessory_model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class Accessory {
264264
}
265265

266266
void addLocationHistoryEntry(FindMyLocationReport report) {
267-
var reportDate = report.timestamp ?? report.published!;
267+
var reportDate = report.timestamp!;
268268
logger.d(
269269
'Adding report with timestamp $reportDate and ${report.longitude} - ${report.latitude}');
270270

macless_haystack/lib/accessory/accessory_registry.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ class AccessoryRegistry extends ChangeNotifier {
119119
if (reports.where((element) => !element.isEncrypted()).isNotEmpty) {
120120
var lastReport =
121121
reports.where((element) => !element.isEncrypted()).first;
122-
var reportDate = (lastReport.timestamp ?? lastReport.published) ??
123-
DateTime.fromMicrosecondsSinceEpoch(0);
122+
var reportDate = lastReport.timestamp ?? DateTime.fromMicrosecondsSinceEpoch(0);
124123
if (accessory.datePublished != null &&
125124
reportDate.isAfter(accessory.datePublished!)) {
126125
accessory.datePublished = reportDate;
@@ -246,7 +245,7 @@ class AccessoryRegistry extends ChangeNotifier {
246245
var lastReport = decryptedReports[decryptedReports.length - 1];
247246
var oldTs = accessory.datePublished;
248247
var latestReportTS =
249-
lastReport.timestamp ?? lastReport.published ?? DateTime(1971);
248+
lastReport.timestamp ?? DateTime(1971);
250249

251250
if (oldTs == null || oldTs.isBefore(latestReportTS)) {
252251
//only an actualization if oldTS is not set or is older than the latest of the new ones

macless_haystack/lib/findMy/decrypt_reports.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class DecryptReports {
105105
latitudeDec,
106106
longitudeDec,
107107
accuracy,
108-
report.datePublished,
109108
report.timestamp,
110109
report.confidence,
111110
batteryStatus);

macless_haystack/lib/findMy/find_my_controller.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,15 @@ class FindMyController {
6565
List jsonResults = await ReportsFetcher.fetchLocationReports(
6666
hashedKeyKeyPairsMap.keys, daysToFetch, url, map['user'], map['pass']);
6767
FindMyLocationReport? latest;
68-
DateTime latestDate = DateTime.fromMicrosecondsSinceEpoch(0);
6968
for (var result in jsonResults) {
70-
DateTime currentDate =
71-
DateTime.fromMillisecondsSinceEpoch(result['datePublished']);
7269
FindMyKeyPair keyPair =
7370
hashedKeyKeyPairsMap[result['id']] as FindMyKeyPair;
7471
var currentReport = FindMyLocationReport.decrypted(
7572
result,
7673
keyPair.getBase64PrivateKey(),
7774
keyPair.getHashedAdvertisementKey(),
7875
);
79-
if (currentDate.isAfter(latestDate)) {
80-
latest = currentReport;
81-
latestDate = currentDate;
82-
}
76+
latest ??= currentReport;
8377
results.add(currentReport);
8478
}
8579
if (latest != null) {

macless_haystack/lib/findMy/models.dart

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class FindMyLocationReport {
2222
double? latitude;
2323
double? longitude;
2424
int? accuracy;
25-
DateTime? published;
2625
DateTime? timestamp;
2726
int? confidence;
2827
AccessoryBatteryStatus? batteryStatus;
@@ -34,7 +33,7 @@ class FindMyLocationReport {
3433
String? hash;
3534

3635
FindMyLocationReport(this.latitude, this.longitude, this.accuracy,
37-
this.published, this.timestamp, this.confidence, this.batteryStatus);
36+
this.timestamp, this.confidence, this.batteryStatus);
3837

3938
FindMyLocationReport.withHash(
4039
this.latitude, this.longitude, this.timestamp, this.hash) {
@@ -60,11 +59,7 @@ class FindMyLocationReport {
6059
await Future.delayed(const Duration(
6160
milliseconds: 1)); //Is needed otherwise is executed synchron
6261
if (isEncrypted()) {
63-
final unixTimestampInMillis = result["datePublished"];
64-
final datePublished =
65-
DateTime.fromMillisecondsSinceEpoch(unixTimestampInMillis);
66-
FindMyReport report = FindMyReport(datePublished,
67-
base64Decode(result["payload"]), id!, result["statusCode"]);
62+
FindMyReport report = FindMyReport(base64Decode(result["payload"]), id!, result["statusCode"]);
6863

6964
FindMyLocationReport decryptedReport =
7065
await DecryptReports.decryptReport(
@@ -102,17 +97,16 @@ class Location {
10297

10398
/// FindMy report returned by the FindMy Network
10499
class FindMyReport {
105-
DateTime datePublished;
106100
Uint8List payload;
107101
String id;
108102
int statusCode;
109103

110104
int? confidence;
111105
DateTime? timestamp;
112106

113-
FindMyReport(this.datePublished, this.payload, this.id, this.statusCode);
107+
FindMyReport(this.payload, this.id, this.statusCode);
114108

115-
FindMyReport.completeInit(this.datePublished, this.payload, this.id,
109+
FindMyReport.completeInit( this.payload, this.id,
116110
this.statusCode, this.confidence, this.timestamp);
117111
}
118112

macless_haystack/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ dependencies:
5555
# Storage
5656
shared_preferences: ^2.5.4
5757
flutter_secure_storage: ^10.0.0
58-
file_picker: ^10.3.8
58+
file_picker: ^10.3.10
5959

6060
# Sharing
6161
share_plus: ^12.0.1
@@ -72,15 +72,15 @@ dependencies:
7272

7373
dev_dependencies:
7474

75-
dependency_validator: ^5.0.3
75+
dependency_validator: ^5.0.4
7676
# The "flutter_lints" package below contains a set of recommended lints to
7777
# encourage good coding practices. The lint set provided by the package is
7878
# activated in the `analysis_options.yaml` file located at the root of your
7979
# package. See that file for information about deactivating specific lint
8080
# rules and activating additional ones.
8181
flutter_lints: ^6.0.0 # Do not update
82-
test: ^1.28.0
83-
mockito: ^5.6.1
82+
test: ^1.30.0
83+
mockito: ^5.6.3
8484

8585
# Configuration for flutter_launcher_icons
8686
flutter_icons:

0 commit comments

Comments
 (0)