Mark deprecated APIs and add the two other versions of provideDiagnosisKeys()

This commit is contained in:
Christian Grigis 2020-11-09 21:15:52 +01:00 committed by Marvin W
parent 42da7aa2fa
commit 5ef1144131
6 changed files with 56 additions and 0 deletions

View File

@ -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<File> files;
public DiagnosisKeyFileProvider(List<File> files) {
this.files = new ArrayList<>(files);
}
public List<File> getFiles() {
return files;
}
}

View File

@ -12,6 +12,7 @@ import org.microg.safeparcel.AutoSafeParcelable;
import java.util.Arrays;
@Deprecated
public class ExposureConfiguration extends AutoSafeParcelable {
@Field(1)
private int minimumRiskScore;

View File

@ -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;

View File

@ -12,6 +12,7 @@ import org.microg.safeparcel.AutoSafeParcelable;
import java.util.Arrays;
@Deprecated
public class ExposureSummary extends AutoSafeParcelable {
@Field(1)
private int daysSinceLastExposure;

View File

@ -24,9 +24,12 @@ public interface ExposureNotificationClient extends HasApiKey<Api.ApiOptions.NoO
String ACTION_EXPOSURE_NOT_FOUND = Constants.ACTION_EXPOSURE_NOT_FOUND;
String ACTION_EXPOSURE_STATE_UPDATED = Constants.ACTION_EXPOSURE_STATE_UPDATED;
String ACTION_SERVICE_STATE_UPDATED = Constants.ACTION_SERVICE_STATE_UPDATED;
@Deprecated
String EXTRA_EXPOSURE_SUMMARY = Constants.EXTRA_EXPOSURE_SUMMARY;
String EXTRA_SERVICE_STATE = Constants.EXTRA_SERVICE_STATE;
@Deprecated
String EXTRA_TOKEN = Constants.EXTRA_TOKEN;
@Deprecated
String TOKEN_A = Constants.TOKEN_A;
Task<Long> getVersion();
@ -41,12 +44,19 @@ public interface ExposureNotificationClient extends HasApiKey<Api.ApiOptions.NoO
Task<List<TemporaryExposureKey>> getTemporaryExposureKeyHistory();
@Deprecated
Task<Void> provideDiagnosisKeys(List<File> keys, ExposureConfiguration configuration, String token);
@Deprecated
Task<Void> provideDiagnosisKeys(List<File> keys);
Task<Void> provideDiagnosisKeys(DiagnosisKeyFileProvider provider);
@Deprecated
Task<ExposureSummary> getExposureSummary(String token);
@Deprecated
Task<List<ExposureInformation>> getExposureInformation(String token);
@Deprecated
Task<List<ExposureWindow>> getExposureWindows(String token);
Task<List<ExposureWindow>> getExposureWindows();

View File

@ -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<Api.ApiOptions.NoO
});
}
@Override
public Task<Void> provideDiagnosisKeys(List<File> keyFiles) {
return provideDiagnosisKeys(keyFiles, null, TOKEN_A);
}
@Override
public Task<Void> 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<ExposureSummary> getExposureSummary(String token) {
return scheduleTask((PendingGoogleApiCall<ExposureSummary, ExposureNotificationApiClient>) (client, completionSource) -> {