From 5ef114413174c5afab229609071e0c08a82e93f0 Mon Sep 17 00:00:00 2001 From: Christian Grigis Date: Mon, 9 Nov 2020 21:15:52 +0100 Subject: [PATCH] Mark deprecated APIs and add the two other versions of provideDiagnosisKeys() --- .../DiagnosisKeyFileProvider.java | 31 +++++++++++++++++++ .../ExposureConfiguration.java | 1 + .../ExposureInformation.java | 1 + .../exposurenotification/ExposureSummary.java | 1 + .../ExposureNotificationClient.java | 10 ++++++ .../ExposureNotificationClientImpl.java | 12 +++++++ 6 files changed, 56 insertions(+) create mode 100644 play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeyFileProvider.java diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeyFileProvider.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeyFileProvider.java new file mode 100644 index 00000000..621201a0 --- /dev/null +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeyFileProvider.java @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + * Notice: Portions of this file are reproduced from work created and shared by Google and used + * according to terms described in the Creative Commons 4.0 Attribution License. + * See https://developers.google.com/readme/policies for details. + */ + +package com.google.android.gms.nearby.exposurenotification; + +import org.microg.gms.common.PublicApi; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * Provider which holds a list of diagnosis key files and can open/supply them one by one as they are ready to be processed. + */ +@PublicApi +public class DiagnosisKeyFileProvider { + private List files; + + public DiagnosisKeyFileProvider(List files) { + this.files = new ArrayList<>(files); + } + + public List getFiles() { + return files; + } +} diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureConfiguration.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureConfiguration.java index 5fe7f650..01cb2a10 100644 --- a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureConfiguration.java +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureConfiguration.java @@ -12,6 +12,7 @@ import org.microg.safeparcel.AutoSafeParcelable; import java.util.Arrays; +@Deprecated public class ExposureConfiguration extends AutoSafeParcelable { @Field(1) private int minimumRiskScore; diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureInformation.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureInformation.java index 8157ce64..fb42ba2d 100644 --- a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureInformation.java +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureInformation.java @@ -13,6 +13,7 @@ import org.microg.safeparcel.AutoSafeParcelable; import java.util.Arrays; import java.util.Date; +@Deprecated public class ExposureInformation extends AutoSafeParcelable { @Field(1) private long dateMillisSinceEpoch; diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureSummary.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureSummary.java index f1fb086a..91852b4b 100644 --- a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureSummary.java +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureSummary.java @@ -12,6 +12,7 @@ import org.microg.safeparcel.AutoSafeParcelable; import java.util.Arrays; +@Deprecated public class ExposureSummary extends AutoSafeParcelable { @Field(1) private int daysSinceLastExposure; diff --git a/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationClient.java b/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationClient.java index 3d9d36e0..38d586fb 100644 --- a/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationClient.java +++ b/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationClient.java @@ -24,9 +24,12 @@ public interface ExposureNotificationClient extends HasApiKey getVersion(); @@ -41,12 +44,19 @@ public interface ExposureNotificationClient extends HasApiKey> getTemporaryExposureKeyHistory(); + @Deprecated Task provideDiagnosisKeys(List keys, ExposureConfiguration configuration, String token); + @Deprecated + Task provideDiagnosisKeys(List keys); + Task provideDiagnosisKeys(DiagnosisKeyFileProvider provider); + @Deprecated Task getExposureSummary(String token); + @Deprecated Task> getExposureInformation(String token); + @Deprecated Task> getExposureWindows(String token); Task> getExposureWindows(); diff --git a/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationClientImpl.java b/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationClientImpl.java index ef723432..583797c8 100644 --- a/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationClientImpl.java +++ b/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationClientImpl.java @@ -17,6 +17,7 @@ import com.google.android.gms.common.api.internal.ApiKey; import com.google.android.gms.common.api.internal.IStatusCallback; import com.google.android.gms.nearby.exposurenotification.DailySummariesConfig; import com.google.android.gms.nearby.exposurenotification.DailySummary; +import com.google.android.gms.nearby.exposurenotification.DiagnosisKeyFileProvider; import com.google.android.gms.nearby.exposurenotification.DiagnosisKeysDataMapping; import com.google.android.gms.nearby.exposurenotification.ExposureConfiguration; import com.google.android.gms.nearby.exposurenotification.ExposureInformation; @@ -231,6 +232,17 @@ public class ExposureNotificationClientImpl extends GoogleApi provideDiagnosisKeys(List keyFiles) { + return provideDiagnosisKeys(keyFiles, null, TOKEN_A); + } + + @Override + public Task provideDiagnosisKeys(DiagnosisKeyFileProvider provider) { + // NOTE: This will probably need to be modified according to how the provider is used + return provideDiagnosisKeys(provider.getFiles()); + } + @Override public Task getExposureSummary(String token) { return scheduleTask((PendingGoogleApiCall) (client, completionSource) -> {