Repo Created
This commit is contained in:
parent
eb305e2886
commit
a8c22c65db
4784 changed files with 329907 additions and 2 deletions
13
play-services-nearby/src/main/AndroidManifest.xml
Normal file
13
play-services-nearby/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ SPDX-FileCopyrightText: 2020 microG Project Team
|
||||
~ SPDX-License-Identifier: Apache-2.0
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application>
|
||||
<service
|
||||
android:name="com.google.android.gms.nearby.exposurenotification.WakeUpService"
|
||||
android:exported="true"
|
||||
android:permission="com.google.android.gms.nearby.exposurenotification.EXPOSURE_CALLBACK"/>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification;
|
||||
|
||||
parcelable DailySummary;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification;
|
||||
|
||||
parcelable DiagnosisKeysDataMapping;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification;
|
||||
|
||||
parcelable ExposureInformation;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification;
|
||||
|
||||
parcelable ExposureSummary;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification;
|
||||
|
||||
parcelable ExposureWindow;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification;
|
||||
|
||||
parcelable PackageConfiguration;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification;
|
||||
|
||||
parcelable TemporaryExposureKey;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetCalibrationConfidenceParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetDailySummariesParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetDiagnosisKeysDataMappingParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetExposureInformationParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetExposureSummaryParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetExposureWindowsParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetPackageConfigurationParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetStatusParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetTemporaryExposureKeyHistoryParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable GetVersionParams;
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
|
||||
interface IBooleanCallback {
|
||||
oneway void onResult(in Status status, boolean result);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.nearby.exposurenotification.DailySummary;
|
||||
|
||||
interface IDailySummaryListCallback {
|
||||
void onResult(in Status status, in List<DailySummary> result);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
interface IDiagnosisKeyFileSupplier {
|
||||
boolean hasNext();
|
||||
ParcelFileDescriptor next();
|
||||
boolean isAvailable();
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.nearby.exposurenotification.DiagnosisKeysDataMapping;
|
||||
|
||||
interface IDiagnosisKeysDataMappingCallback {
|
||||
void onResult(in Status status, in DiagnosisKeysDataMapping result);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureInformation;
|
||||
|
||||
interface IExposureInformationListCallback {
|
||||
void onResult(in Status status, in List<ExposureInformation> result);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureSummary;
|
||||
|
||||
interface IExposureSummaryCallback {
|
||||
void onResult(in Status status, in ExposureSummary result);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureWindow;
|
||||
|
||||
interface IExposureWindowListCallback {
|
||||
void onResult(in Status status, in List<ExposureWindow> result);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
|
||||
interface IIntCallback {
|
||||
void onResult(in Status status, int result);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
|
||||
interface ILongCallback {
|
||||
void onResult(in Status status, long result);
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.StartParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.StopParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IsEnabledParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetTemporaryExposureKeyHistoryParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.ProvideDiagnosisKeysParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetExposureSummaryParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetExposureInformationParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetExposureWindowsParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetVersionParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetCalibrationConfidenceParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetDailySummariesParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.SetDiagnosisKeysDataMappingParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetDiagnosisKeysDataMappingParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetStatusParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetPackageConfigurationParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.RequestPreAuthorizedTemporaryExposureKeyHistoryParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.RequestPreAuthorizedTemporaryExposureKeyReleaseParams;
|
||||
|
||||
interface INearbyExposureNotificationService{
|
||||
oneway void start(in StartParams params) = 0;
|
||||
oneway void stop(in StopParams params) = 1;
|
||||
oneway void isEnabled(in IsEnabledParams params) = 2;
|
||||
oneway void getTemporaryExposureKeyHistory(in GetTemporaryExposureKeyHistoryParams params) = 3;
|
||||
oneway void provideDiagnosisKeys(in ProvideDiagnosisKeysParams params) = 4;
|
||||
//oneway void getMaxDiagnosisKeyCount(in GetMaxDiagnosisKeyCountParams params) = 5;
|
||||
oneway void getExposureSummary(in GetExposureSummaryParams params) = 6;
|
||||
oneway void getExposureInformation(in GetExposureInformationParams params) = 7;
|
||||
//oneway void resetAllData(in ResetAllDataParams params) = 8;
|
||||
//oneway void resetTemporaryExposureKeys(in ResetTemporaryExposureKeysParams params) = 9;
|
||||
//oneway void startForPackage(in StartForPackageParams params) = 10;
|
||||
//oneway void isEnabledForPackage(in IsEnabledForPackageParams params) = 11;
|
||||
oneway void getExposureWindows(in GetExposureWindowsParams params) = 12;
|
||||
oneway void getVersion(in GetVersionParams params) = 13;
|
||||
oneway void getCalibrationConfidence(in GetCalibrationConfidenceParams params) = 14;
|
||||
oneway void getDailySummaries(in GetDailySummariesParams params) = 15;
|
||||
oneway void setDiagnosisKeysDataMapping(in SetDiagnosisKeysDataMappingParams params) = 16;
|
||||
oneway void getDiagnosisKeysDataMapping(in GetDiagnosisKeysDataMappingParams params) = 17;
|
||||
oneway void getStatus(in GetStatusParams params) = 18;
|
||||
oneway void getPackageConfiguration(in GetPackageConfigurationParams params) = 19;
|
||||
oneway void requestPreAuthorizedTemporaryExposureKeyHistory(in RequestPreAuthorizedTemporaryExposureKeyHistoryParams params) = 20;
|
||||
oneway void requestPreAuthorizedTemporaryExposureKeyRelease(in RequestPreAuthorizedTemporaryExposureKeyReleaseParams params) = 21;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.nearby.exposurenotification.PackageConfiguration;
|
||||
|
||||
interface IPackageConfigurationCallback {
|
||||
void onResult(in Status status, in PackageConfiguration result);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.Status;
|
||||
import com.google.android.gms.nearby.exposurenotification.TemporaryExposureKey;
|
||||
|
||||
interface ITemporaryExposureKeyListCallback {
|
||||
void onResult(in Status status, in List<TemporaryExposureKey> result);
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable IsEnabledParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable ProvideDiagnosisKeysParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable RequestPreAuthorizedTemporaryExposureKeyHistoryParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable RequestPreAuthorizedTemporaryExposureKeyReleaseParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable SetDiagnosisKeysDataMappingParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable StartParams;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
parcelable StopParams;
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.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;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureNotificationClient;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
import org.microg.gms.nearby.ExposureNotificationClientImpl;
|
||||
|
||||
@PublicApi
|
||||
public class Nearby {
|
||||
public static ExposureNotificationClient getExposureNotificationClient(Context context) {
|
||||
return new ExposureNotificationClientImpl(context);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Calibration confidence defined for an {@link ExposureWindow}.
|
||||
*/
|
||||
@PublicApi
|
||||
public @interface CalibrationConfidence {
|
||||
/**
|
||||
* No calibration data, using fleet-wide as default options.
|
||||
*/
|
||||
int LOWEST = 0;
|
||||
/**
|
||||
* Using average calibration over models from manufacturer.
|
||||
*/
|
||||
int LOW = 1;
|
||||
/**
|
||||
* Using single-antenna orientation for a similar model.
|
||||
*/
|
||||
int MEDIUM = 2;
|
||||
/**
|
||||
* Using significant calibration data for this model.
|
||||
*/
|
||||
int HIGH = 3;
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
int VALUES = 4;
|
||||
}
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
/*
|
||||
* 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 org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Configuration of per-day summary of exposures.
|
||||
* <p>
|
||||
* During summarization the following are computed for each ExposureWindows:
|
||||
* <ul>
|
||||
* <li>a weighted duration, computed as
|
||||
* {@code ( immediateDurationSeconds * immediateDurationWeight ) + ( nearDurationSeconds * nearDurationWeight ) + ( mediumDurationSeconds * mediumDurationWeight ) + ( otherDurationSeconds * otherDurationWeight )}</li>
|
||||
* <li>a score, computed as
|
||||
* {@code reportTypeWeights[Tek.reportType] * infectiousnessWeights[infectiousness] * weightedDuration}
|
||||
* where infectiousness and reportType are set based on the ExposureWindow's diagnosis key and the DiagnosisKeysDataMapping</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* The {@link ExposureWindow}s are then filtered, removing those with score lower than {@link #getMinimumWindowScore()}.
|
||||
* <p>
|
||||
* Scores and weighted durations of the {@link ExposureWindow}s that pass the {@link #getMinimumWindowScore()} are then aggregated over a day to compute the maximum and cumulative scores and duration:
|
||||
* <ul>
|
||||
* <li>sumScore = sum(score of ExposureWindows)</li>
|
||||
* <li>maxScore = max(score of ExposureWindows)</li>
|
||||
* <li>weightedDurationSum = sum(weighted duration of ExposureWindow)</li>
|
||||
* </ul>
|
||||
* Note that when the weights are typically around 100% (1.0), both the scores and the weightedDurationSum can be considered as being expressed in seconds. For example, 15 minutes of exposure with all weights equal to 1.0 would be 60 * 15 = 900 (seconds).
|
||||
*/
|
||||
@PublicApi
|
||||
public class DailySummariesConfig extends AutoSafeParcelable {
|
||||
@Field(value = 1, useDirectList = true)
|
||||
private List<Double> reportTypeWeights;
|
||||
@Field(value = 2, useDirectList = true)
|
||||
private List<Double> infectiousnessWeights;
|
||||
@Field(value = 3, useDirectList = true)
|
||||
private List<Integer> attenuationBucketThresholdDb;
|
||||
@Field(value = 4, useDirectList = true)
|
||||
private List<Double> attenuationBucketWeights;
|
||||
@Field(5)
|
||||
private int daysSinceExposureThreshold;
|
||||
@Field(6)
|
||||
private double minimumWindowScore;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof DailySummariesConfig)) return false;
|
||||
|
||||
DailySummariesConfig that = (DailySummariesConfig) o;
|
||||
|
||||
if (daysSinceExposureThreshold != that.daysSinceExposureThreshold) return false;
|
||||
if (Double.compare(that.minimumWindowScore, minimumWindowScore) != 0) return false;
|
||||
if (reportTypeWeights != null ? !reportTypeWeights.equals(that.reportTypeWeights) : that.reportTypeWeights != null)
|
||||
return false;
|
||||
if (infectiousnessWeights != null ? !infectiousnessWeights.equals(that.infectiousnessWeights) : that.infectiousnessWeights != null)
|
||||
return false;
|
||||
if (attenuationBucketThresholdDb != null ? !attenuationBucketThresholdDb.equals(that.attenuationBucketThresholdDb) : that.attenuationBucketThresholdDb != null)
|
||||
return false;
|
||||
return attenuationBucketWeights != null ? attenuationBucketWeights.equals(that.attenuationBucketWeights) : that.attenuationBucketWeights == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Thresholds defining the BLE attenuation buckets edges.
|
||||
* <p>
|
||||
* This list must have 3 elements: the immediate, near, and medium thresholds. See attenuationBucketWeights for more information.
|
||||
* <p>
|
||||
* These elements must be between 0 and 255 and come in increasing order.
|
||||
*/
|
||||
public List<Integer> getAttenuationBucketThresholdDb() {
|
||||
return attenuationBucketThresholdDb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scoring weights to associate with ScanInstances depending on the attenuation bucket in which their typicalAttenuationDb falls.
|
||||
* <p>
|
||||
* This list must have 4 elements, corresponding to the weights for the 4 buckets.
|
||||
* <ul>
|
||||
* <li>immediate bucket: -infinity < attenuation <= immediate threshold</li>
|
||||
* <li>near bucket: immediate threshold < attenuation <= near threshold</li>
|
||||
* <li>medium bucket: near threshold < attenuation <= medium threshold</li>
|
||||
* <li>other bucket: medium threshold < attenuation < +infinity</li>
|
||||
* </ul>
|
||||
* Each element must be between 0 and 2.5.
|
||||
*/
|
||||
public List<Double> getAttenuationBucketWeights() {
|
||||
return attenuationBucketWeights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reserved for future use, behavior will be changed in future revisions. No value should be set, or else 0 should be used.
|
||||
*/
|
||||
public int getDaysSinceExposureThreshold() {
|
||||
return daysSinceExposureThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scoring weights to associate with exposures with different Infectiousness.
|
||||
* <p>
|
||||
* This map can include weights for the following Infectiousness values:
|
||||
* <ul>
|
||||
* <li>STANDARD</li>
|
||||
* <li>HIGH</li>
|
||||
* </ul>
|
||||
* Each element must be between 0 and 2.5.
|
||||
*/
|
||||
public Map<Integer, Double> getInfectiousnessWeights() {
|
||||
HashMap<Integer, Double> map = new HashMap<>();
|
||||
for (int i = 0; i < infectiousnessWeights.size(); i++) {
|
||||
map.put(i, infectiousnessWeights.get(i));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimum score that {@link ExposureWindow}s must reach in order to be included in the {@link DailySummary.ExposureSummaryData}.
|
||||
* <p>
|
||||
* Use 0 to consider all {@link ExposureWindow}s (recommended).
|
||||
*/
|
||||
public double getMinimumWindowScore() {
|
||||
return minimumWindowScore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scoring weights to associate with exposures with different ReportTypes.
|
||||
* <p>
|
||||
* This map can include weights for the following ReportTypes:
|
||||
* <ul>
|
||||
* <li>CONFIRMED_TEST</li>
|
||||
* <li>CONFIRMED_CLINICAL_DIAGNOSIS</li>
|
||||
* <li>SELF_REPORT</li>
|
||||
* <li>RECURSIVE (reserved for future use)</li>
|
||||
* </ul>
|
||||
* Each element must be between 0 and 2.5.
|
||||
*/
|
||||
public Map<Integer, Double> getReportTypeWeights() {
|
||||
HashMap<Integer, Double> map = new HashMap<>();
|
||||
for (int i = 0; i < reportTypeWeights.size(); i++) {
|
||||
map.put(i, reportTypeWeights.get(i));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
result = reportTypeWeights != null ? reportTypeWeights.hashCode() : 0;
|
||||
result = 31 * result + (infectiousnessWeights != null ? infectiousnessWeights.hashCode() : 0);
|
||||
result = 31 * result + (attenuationBucketThresholdDb != null ? attenuationBucketThresholdDb.hashCode() : 0);
|
||||
result = 31 * result + (attenuationBucketWeights != null ? attenuationBucketWeights.hashCode() : 0);
|
||||
result = 31 * result + daysSinceExposureThreshold;
|
||||
temp = Double.doubleToLongBits(minimumWindowScore);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for {@link DailySummariesConfig}.
|
||||
*/
|
||||
public static class DailySummariesConfigBuilder {
|
||||
private Double[] reportTypeWeights = new Double[ReportType.VALUES];
|
||||
private Double[] infectiousnessWeights = new Double[Infectiousness.VALUES];
|
||||
private List<Integer> attenuationBucketThresholdDb;
|
||||
private List<Double> attenuationBucketWeights;
|
||||
private int daysSinceExposureThreshold;
|
||||
private double minimumWindowScore;
|
||||
|
||||
public DailySummariesConfigBuilder() {
|
||||
Arrays.fill(reportTypeWeights, 0.0);
|
||||
Arrays.fill(infectiousnessWeights, 0.0);
|
||||
}
|
||||
|
||||
public DailySummariesConfig build() {
|
||||
if (attenuationBucketThresholdDb == null)
|
||||
throw new IllegalStateException("Must set attenuationBucketThresholdDb");
|
||||
if (attenuationBucketWeights == null)
|
||||
throw new IllegalStateException("Must set attenuationBucketWeights");
|
||||
DailySummariesConfig config = new DailySummariesConfig();
|
||||
config.reportTypeWeights = Arrays.asList(reportTypeWeights);
|
||||
config.infectiousnessWeights = Arrays.asList(infectiousnessWeights);
|
||||
config.attenuationBucketThresholdDb = attenuationBucketThresholdDb;
|
||||
config.attenuationBucketWeights = attenuationBucketWeights;
|
||||
config.daysSinceExposureThreshold = daysSinceExposureThreshold;
|
||||
config.minimumWindowScore = minimumWindowScore;
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #getAttenuationBucketThresholdDb()} and {@link #getAttenuationBucketWeights()}
|
||||
*/
|
||||
public DailySummariesConfigBuilder setAttenuationBuckets(List<Integer> thresholds, List<Double> weights) {
|
||||
attenuationBucketThresholdDb = new ArrayList<>(thresholds);
|
||||
attenuationBucketWeights = new ArrayList<>(weights);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #getDaysSinceExposureThreshold()}
|
||||
*/
|
||||
public DailySummariesConfigBuilder setDaysSinceExposureThreshold(int daysSinceExposureThreshold) {
|
||||
this.daysSinceExposureThreshold = daysSinceExposureThreshold;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #getInfectiousnessWeights()}
|
||||
*/
|
||||
public DailySummariesConfigBuilder setInfectiousnessWeight(@Infectiousness int infectiousness, double weight) {
|
||||
infectiousnessWeights[infectiousness] = weight;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #getMinimumWindowScore()}
|
||||
*/
|
||||
public DailySummariesConfigBuilder setMinimumWindowScore(double minimumWindowScore) {
|
||||
this.minimumWindowScore = minimumWindowScore;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #getReportTypeWeights()}
|
||||
*/
|
||||
public DailySummariesConfigBuilder setReportTypeWeight(@ReportType int reportType, double weight) {
|
||||
reportTypeWeights[reportType] = weight;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<DailySummariesConfig> CREATOR = new AutoCreator<>(DailySummariesConfig.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* 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 org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Daily exposure summary to pass to client side.
|
||||
*/
|
||||
@PublicApi
|
||||
public class DailySummary extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
private int daysSinceEpoch;
|
||||
@Field(2)
|
||||
private List<ExposureSummaryData> reportSummaries;
|
||||
@Field(3)
|
||||
private ExposureSummaryData summaryData;
|
||||
|
||||
private DailySummary() {
|
||||
}
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
public DailySummary(int daysSinceEpoch, List<ExposureSummaryData> reportSummaries, ExposureSummaryData summaryData) {
|
||||
this.daysSinceEpoch = daysSinceEpoch;
|
||||
this.reportSummaries = reportSummaries;
|
||||
this.summaryData = summaryData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof DailySummary)) return false;
|
||||
|
||||
DailySummary that = (DailySummary) o;
|
||||
|
||||
if (daysSinceEpoch != that.daysSinceEpoch) return false;
|
||||
if (reportSummaries != null ? !reportSummaries.equals(that.reportSummaries) : that.reportSummaries != null)
|
||||
return false;
|
||||
return summaryData != null ? summaryData.equals(that.summaryData) : that.summaryData == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns days since epoch of the {@link ExposureWindow}s that went into this summary.
|
||||
*/
|
||||
public int getDaysSinceEpoch() {
|
||||
return daysSinceEpoch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of all exposures on this day.
|
||||
*/
|
||||
public ExposureSummaryData getSummaryData() {
|
||||
return summaryData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of all exposures on this day of a specific diagnosis {@link ReportType}.
|
||||
*/
|
||||
public ExposureSummaryData getSummaryDataForReportType(@ReportType int reportType) {
|
||||
return reportSummaries.get(reportType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = daysSinceEpoch;
|
||||
result = 31 * result + (reportSummaries != null ? reportSummaries.hashCode() : 0);
|
||||
result = 31 * result + (summaryData != null ? summaryData.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores different scores for specific {@link ReportType}.
|
||||
*/
|
||||
public static class ExposureSummaryData extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
private double maximumScore;
|
||||
@Field(2)
|
||||
private double scoreSum;
|
||||
@Field(3)
|
||||
private double weightedDurationSum;
|
||||
|
||||
private ExposureSummaryData() {
|
||||
}
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
public ExposureSummaryData(double maximumScore, double scoreSum, double weightedDurationSum) {
|
||||
this.maximumScore = maximumScore;
|
||||
this.scoreSum = scoreSum;
|
||||
this.weightedDurationSum = weightedDurationSum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ExposureSummaryData)) return false;
|
||||
|
||||
ExposureSummaryData that = (ExposureSummaryData) o;
|
||||
|
||||
if (Double.compare(that.maximumScore, maximumScore) != 0) return false;
|
||||
if (Double.compare(that.scoreSum, scoreSum) != 0) return false;
|
||||
return Double.compare(that.weightedDurationSum, weightedDurationSum) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Highest score of all {@link ExposureWindow}s aggregated into this summary.
|
||||
* <p>
|
||||
* See {@link DailySummariesConfig} for more information about how the per-{@link ExposureWindow} score is computed.
|
||||
*/
|
||||
public double getMaximumScore() {
|
||||
return maximumScore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sum of scores for all {@link ExposureWindow}s aggregated into this summary.
|
||||
* <p>
|
||||
* See {@link DailySummariesConfig} for more information about how the per-{@link ExposureWindow} score is computed.
|
||||
*/
|
||||
public double getScoreSum() {
|
||||
return scoreSum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sum of weighted durations for all {@link ExposureWindow}s aggregated into this summary.
|
||||
* <p>
|
||||
* See {@link DailySummariesConfig} for more information about how the per-{@link ExposureWindow} score is computed.
|
||||
*/
|
||||
public double getWeightedDurationSum() {
|
||||
return weightedDurationSum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(maximumScore);
|
||||
result = (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(scoreSum);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(weightedDurationSum);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static final Creator<ExposureSummaryData> CREATOR = new AutoCreator<>(ExposureSummaryData.class);
|
||||
}
|
||||
|
||||
public static final Creator<DailySummary> CREATOR = new AutoCreator<>(DailySummary.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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 int index;
|
||||
private List<File> files;
|
||||
|
||||
public DiagnosisKeyFileProvider(List<File> files) {
|
||||
this.files = new ArrayList<>(files);
|
||||
}
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
public boolean hasNext() {
|
||||
return files.size() > index;
|
||||
}
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
public File next() {
|
||||
return files.get(index++);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* 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 org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mappings from diagnosis keys data to concepts returned by the API.
|
||||
*/
|
||||
@PublicApi
|
||||
public class DiagnosisKeysDataMapping extends AutoSafeParcelable {
|
||||
@Field(value = 1, useDirectList = true)
|
||||
private List<Integer> daysSinceOnsetToInfectiousness = new ArrayList<>();
|
||||
@Field(2)
|
||||
@ReportType
|
||||
private int reportTypeWhenMissing;
|
||||
@Field(3)
|
||||
@Infectiousness
|
||||
private int infectiousnessWhenDaysSinceOnsetMissing;
|
||||
|
||||
/**
|
||||
* Mapping from diagnosisKey.daysSinceOnsetOfSymptoms to {@link Infectiousness}.
|
||||
* <p>
|
||||
* Infectiousness is computed from this mapping and the tek metadata as - daysSinceOnsetToInfectiousness[{@link TemporaryExposureKey#getDaysSinceOnsetOfSymptoms()}], or - {@link #getInfectiousnessWhenDaysSinceOnsetMissing()} if {@link TemporaryExposureKey#getDaysSinceOnsetOfSymptoms()} is {@link TemporaryExposureKey#DAYS_SINCE_ONSET_OF_SYMPTOMS_UNKNOWN}.
|
||||
* <p>
|
||||
* Values of DaysSinceOnsetOfSymptoms that aren't represented in this map are given {@link Infectiousness#NONE} as infectiousness. Exposures with infectiousness equal to {@link Infectiousness#NONE} are dropped.
|
||||
*/
|
||||
public Map<Integer, Integer> getDaysSinceOnsetToInfectiousness() {
|
||||
HashMap<Integer, Integer> map = new HashMap<>();
|
||||
for (int i = 0; i < daysSinceOnsetToInfectiousness.size(); i++) {
|
||||
map.put(i, daysSinceOnsetToInfectiousness.get(i));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Infectiousness of TEKs for which onset of symptoms is not set.
|
||||
* <p>
|
||||
* See {@link #getDaysSinceOnsetToInfectiousness()} for more info.
|
||||
*/
|
||||
public int getInfectiousnessWhenDaysSinceOnsetMissing() {
|
||||
return infectiousnessWhenDaysSinceOnsetMissing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report type to default to when a TEK has no report type set.
|
||||
* <p>
|
||||
* This report type gets used when creating the {@link ExposureWindow}s and the {@link DailySummary}s. The system will treat TEKs with missing report types as if they had this provided report type.
|
||||
*/
|
||||
public int getReportTypeWhenMissing() {
|
||||
return reportTypeWhenMissing;
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for {@link DiagnosisKeysDataMapping}.
|
||||
*/
|
||||
public static class DiagnosisKeysDataMappingBuilder {
|
||||
private final static int MAX_DAYS = 29;
|
||||
private List<Integer> daysSinceOnsetToInfectiousness;
|
||||
@ReportType
|
||||
private int reportTypeWhenMissing = ReportType.UNKNOWN;
|
||||
@Infectiousness
|
||||
private Integer infectiousnessWhenDaysSinceOnsetMissing;
|
||||
|
||||
public DiagnosisKeysDataMapping build() {
|
||||
if (daysSinceOnsetToInfectiousness == null)
|
||||
throw new IllegalStateException("Must set daysSinceOnsetToInfectiousness");
|
||||
if (reportTypeWhenMissing == ReportType.UNKNOWN)
|
||||
throw new IllegalStateException("Must set reportTypeWhenMissing");
|
||||
if (infectiousnessWhenDaysSinceOnsetMissing == null)
|
||||
throw new IllegalStateException("Must set infectiousnessWhenDaysSinceOnsetMissing");
|
||||
DiagnosisKeysDataMapping mapping = new DiagnosisKeysDataMapping();
|
||||
mapping.daysSinceOnsetToInfectiousness = new ArrayList<>(daysSinceOnsetToInfectiousness);
|
||||
mapping.reportTypeWhenMissing = reportTypeWhenMissing;
|
||||
mapping.infectiousnessWhenDaysSinceOnsetMissing = infectiousnessWhenDaysSinceOnsetMissing;
|
||||
return mapping;
|
||||
}
|
||||
|
||||
public DiagnosisKeysDataMappingBuilder setDaysSinceOnsetToInfectiousness(Map<Integer, Integer> daysSinceOnsetToInfectiousness) {
|
||||
if (daysSinceOnsetToInfectiousness.size() > MAX_DAYS)
|
||||
throw new IllegalArgumentException("daysSinceOnsetToInfectiousness exceeds " + MAX_DAYS + " days");
|
||||
Integer[] values = new Integer[MAX_DAYS];
|
||||
Arrays.fill(values, 0);
|
||||
for (Map.Entry<Integer, Integer> entry : daysSinceOnsetToInfectiousness.entrySet()) {
|
||||
if (entry.getKey() > 14) throw new IllegalArgumentException("invalid day since onset");
|
||||
values[entry.getKey() + 14] = entry.getValue();
|
||||
}
|
||||
this.daysSinceOnsetToInfectiousness = Arrays.asList(values);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DiagnosisKeysDataMappingBuilder setInfectiousnessWhenDaysSinceOnsetMissing(@Infectiousness int infectiousnessWhenDaysSinceOnsetMissing) {
|
||||
this.infectiousnessWhenDaysSinceOnsetMissing = infectiousnessWhenDaysSinceOnsetMissing;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DiagnosisKeysDataMappingBuilder setReportTypeWhenMissing(@ReportType int reportTypeWhenMissing) {
|
||||
this.reportTypeWhenMissing = reportTypeWhenMissing;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<DiagnosisKeysDataMapping> CREATOR = new AutoCreator<>(DiagnosisKeysDataMapping.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.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.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Deprecated
|
||||
public class ExposureConfiguration extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
private int minimumRiskScore;
|
||||
@Field(2)
|
||||
private int[] attenuationScores;
|
||||
@Field(3)
|
||||
private int attenuationWeight;
|
||||
@Field(4)
|
||||
private int[] daysSinceLastExposureScores;
|
||||
@Field(5)
|
||||
private int daysSinceLastExposureWeight;
|
||||
@Field(6)
|
||||
private int[] durationScores;
|
||||
@Field(7)
|
||||
private int durationWeight;
|
||||
@Field(8)
|
||||
private int[] transmissionRiskScores;
|
||||
@Field(9)
|
||||
private int transmissionRiskWeight;
|
||||
@Field(10)
|
||||
private int[] durationAtAttenuationThresholds;
|
||||
|
||||
private ExposureConfiguration() {
|
||||
}
|
||||
|
||||
ExposureConfiguration(int minimumRiskScore, int[] attenuationScores, int attenuationWeight, int[] daysSinceLastExposureScores, int daysSinceLastExposureWeight, int[] durationScores, int durationWeight, int[] transmissionRiskScores, int transmissionRiskWeight, int[] durationAtAttenuationThresholds) {
|
||||
this.minimumRiskScore = minimumRiskScore;
|
||||
this.attenuationScores = attenuationScores;
|
||||
this.attenuationWeight = attenuationWeight;
|
||||
this.daysSinceLastExposureScores = daysSinceLastExposureScores;
|
||||
this.daysSinceLastExposureWeight = daysSinceLastExposureWeight;
|
||||
this.durationScores = durationScores;
|
||||
this.durationWeight = durationWeight;
|
||||
this.transmissionRiskScores = transmissionRiskScores;
|
||||
this.transmissionRiskWeight = transmissionRiskWeight;
|
||||
this.durationAtAttenuationThresholds = durationAtAttenuationThresholds;
|
||||
}
|
||||
|
||||
public int getMinimumRiskScore() {
|
||||
return minimumRiskScore;
|
||||
}
|
||||
|
||||
public int[] getAttenuationScores() {
|
||||
return Arrays.copyOf(attenuationScores, attenuationScores.length);
|
||||
}
|
||||
|
||||
public int getAttenuationWeight() {
|
||||
return attenuationWeight;
|
||||
}
|
||||
|
||||
public int[] getDaysSinceLastExposureScores() {
|
||||
return Arrays.copyOf(daysSinceLastExposureScores, daysSinceLastExposureScores.length);
|
||||
}
|
||||
|
||||
public int getDaysSinceLastExposureWeight() {
|
||||
return daysSinceLastExposureWeight;
|
||||
}
|
||||
|
||||
public int[] getDurationScores() {
|
||||
return Arrays.copyOf(durationScores, durationScores.length);
|
||||
}
|
||||
|
||||
public int getDurationWeight() {
|
||||
return durationWeight;
|
||||
}
|
||||
|
||||
public int[] getTransmissionRiskScores() {
|
||||
return Arrays.copyOf(transmissionRiskScores, transmissionRiskScores.length);
|
||||
}
|
||||
|
||||
public int getTransmissionRiskWeight() {
|
||||
return transmissionRiskWeight;
|
||||
}
|
||||
|
||||
public int[] getDurationAtAttenuationThresholds() {
|
||||
return Arrays.copyOf(durationAtAttenuationThresholds, durationAtAttenuationThresholds.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ExposureConfiguration that = (ExposureConfiguration) o;
|
||||
|
||||
if (minimumRiskScore != that.minimumRiskScore) return false;
|
||||
if (attenuationWeight != that.attenuationWeight) return false;
|
||||
if (daysSinceLastExposureWeight != that.daysSinceLastExposureWeight) return false;
|
||||
if (durationWeight != that.durationWeight) return false;
|
||||
if (transmissionRiskWeight != that.transmissionRiskWeight) return false;
|
||||
if (!Arrays.equals(attenuationScores, that.attenuationScores)) return false;
|
||||
if (!Arrays.equals(daysSinceLastExposureScores, that.daysSinceLastExposureScores)) return false;
|
||||
if (!Arrays.equals(durationScores, that.durationScores)) return false;
|
||||
if (!Arrays.equals(transmissionRiskScores, that.transmissionRiskScores)) return false;
|
||||
return Arrays.equals(durationAtAttenuationThresholds, that.durationAtAttenuationThresholds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = minimumRiskScore;
|
||||
result = 31 * result + Arrays.hashCode(attenuationScores);
|
||||
result = 31 * result + attenuationWeight;
|
||||
result = 31 * result + Arrays.hashCode(daysSinceLastExposureScores);
|
||||
result = 31 * result + daysSinceLastExposureWeight;
|
||||
result = 31 * result + Arrays.hashCode(durationScores);
|
||||
result = 31 * result + durationWeight;
|
||||
result = 31 * result + Arrays.hashCode(transmissionRiskScores);
|
||||
result = 31 * result + transmissionRiskWeight;
|
||||
result = 31 * result + Arrays.hashCode(durationAtAttenuationThresholds);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExposureConfiguration{" +
|
||||
"minimumRiskScore=" + minimumRiskScore +
|
||||
", attenuationScores=" + Arrays.toString(attenuationScores) +
|
||||
", attenuationWeight=" + attenuationWeight +
|
||||
", daysSinceLastExposureScores=" + Arrays.toString(daysSinceLastExposureScores) +
|
||||
", daysSinceLastExposureWeight=" + daysSinceLastExposureWeight +
|
||||
", durationScores=" + Arrays.toString(durationScores) +
|
||||
", durationWeight=" + durationWeight +
|
||||
", transmissionRiskScores=" + Arrays.toString(transmissionRiskScores) +
|
||||
", transmissionRiskWeight=" + transmissionRiskWeight +
|
||||
", durationAtAttenuationThresholds=" + Arrays.toString(durationAtAttenuationThresholds) +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class ExposureConfigurationBuilder {
|
||||
private int minimumRiskScore = 4;
|
||||
private int[] attenuationScores = new int[]{4, 4, 4, 4, 4, 4, 4, 4};
|
||||
private int attenuationWeight = 50;
|
||||
private int[] daysSinceLastExposureScores = new int[]{4, 4, 4, 4, 4, 4, 4, 4};
|
||||
private int daysSinceLastExposureWeight = 50;
|
||||
private int[] durationScores = new int[]{4, 4, 4, 4, 4, 4, 4, 4};
|
||||
private int durationWeight = 50;
|
||||
private int[] transmissionRiskScores = new int[]{4, 4, 4, 4, 4, 4, 4, 4};
|
||||
private int transmissionRiskWeight = 50;
|
||||
private int[] durationAtAttenuationThresholds = new int[]{50, 74};
|
||||
|
||||
public ExposureConfigurationBuilder setMinimumRiskScore(int minimumRiskScore) {
|
||||
this.minimumRiskScore = minimumRiskScore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfigurationBuilder setAttenuationScores(int... attenuationScores) {
|
||||
this.attenuationScores = Arrays.copyOf(attenuationScores, attenuationScores.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfigurationBuilder setAttenuationWeight(int attenuationWeight) {
|
||||
this.attenuationWeight = attenuationWeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfigurationBuilder setDaysSinceLastExposureScores(int... daysSinceLastExposureScores) {
|
||||
this.daysSinceLastExposureScores = Arrays.copyOf(daysSinceLastExposureScores, daysSinceLastExposureScores.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfigurationBuilder setDaysSinceLastExposureWeight(int daysSinceLastExposureWeight) {
|
||||
this.daysSinceLastExposureWeight = daysSinceLastExposureWeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfigurationBuilder setDurationScores(int... durationScores) {
|
||||
this.durationScores = Arrays.copyOf(durationScores, durationScores.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfigurationBuilder setDurationWeight(int durationWeight) {
|
||||
this.durationWeight = durationWeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfigurationBuilder setTransmissionRiskScores(int... transmissionRiskScores) {
|
||||
this.transmissionRiskScores = Arrays.copyOf(transmissionRiskScores, transmissionRiskScores.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfigurationBuilder setTransmissionRiskWeight(int transmissionRiskWeight) {
|
||||
this.transmissionRiskWeight = transmissionRiskWeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfigurationBuilder setDurationAtAttenuationThresholds(int... durationAtAttenuationThresholds) {
|
||||
this.durationAtAttenuationThresholds = Arrays.copyOf(durationAtAttenuationThresholds, durationAtAttenuationThresholds.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureConfiguration build() {
|
||||
return new ExposureConfiguration(minimumRiskScore, attenuationScores, attenuationWeight, daysSinceLastExposureScores, daysSinceLastExposureWeight, durationScores, durationWeight, transmissionRiskScores, transmissionRiskWeight, durationAtAttenuationThresholds);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<ExposureConfiguration> CREATOR = new AutoCreator<>(ExposureConfiguration.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.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.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
@Deprecated
|
||||
public class ExposureInformation extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
private long dateMillisSinceEpoch;
|
||||
@Field(2)
|
||||
private int durationMinutes;
|
||||
@Field(3)
|
||||
private int attenuationValue;
|
||||
@Field(4)
|
||||
@RiskLevel
|
||||
private int transmissionRiskLevel;
|
||||
@Field(5)
|
||||
private int totalRiskScore;
|
||||
@Field(6)
|
||||
private int[] attenuationDurationsInMinutes;
|
||||
|
||||
private ExposureInformation() {
|
||||
}
|
||||
|
||||
ExposureInformation(long dateMillisSinceEpoch, int durationMinutes, int attenuationValue, @RiskLevel int transmissionRiskLevel, int totalRiskScore, int[] attenuationDurationsInMinutes) {
|
||||
this.dateMillisSinceEpoch = dateMillisSinceEpoch;
|
||||
this.durationMinutes = durationMinutes;
|
||||
this.attenuationValue = attenuationValue;
|
||||
this.transmissionRiskLevel = transmissionRiskLevel;
|
||||
this.totalRiskScore = totalRiskScore;
|
||||
this.attenuationDurationsInMinutes = attenuationDurationsInMinutes;
|
||||
}
|
||||
|
||||
public long getDateMillisSinceEpoch() {
|
||||
return dateMillisSinceEpoch;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return new Date(dateMillisSinceEpoch);
|
||||
}
|
||||
|
||||
public int getDurationMinutes() {
|
||||
return durationMinutes;
|
||||
}
|
||||
|
||||
public int getAttenuationValue() {
|
||||
return attenuationValue;
|
||||
}
|
||||
|
||||
@RiskLevel
|
||||
public int getTransmissionRiskLevel() {
|
||||
return transmissionRiskLevel;
|
||||
}
|
||||
|
||||
public int getTotalRiskScore() {
|
||||
return totalRiskScore;
|
||||
}
|
||||
|
||||
public int[] getAttenuationDurationsInMinutes() {
|
||||
return Arrays.copyOf(attenuationDurationsInMinutes, attenuationDurationsInMinutes.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ExposureInformation that = (ExposureInformation) o;
|
||||
|
||||
if (dateMillisSinceEpoch != that.dateMillisSinceEpoch) return false;
|
||||
if (durationMinutes != that.durationMinutes) return false;
|
||||
if (attenuationValue != that.attenuationValue) return false;
|
||||
if (transmissionRiskLevel != that.transmissionRiskLevel) return false;
|
||||
if (totalRiskScore != that.totalRiskScore) return false;
|
||||
return Arrays.equals(attenuationDurationsInMinutes, that.attenuationDurationsInMinutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (int) (dateMillisSinceEpoch ^ (dateMillisSinceEpoch >>> 32));
|
||||
result = 31 * result + durationMinutes;
|
||||
result = 31 * result + attenuationValue;
|
||||
result = 31 * result + transmissionRiskLevel;
|
||||
result = 31 * result + totalRiskScore;
|
||||
result = 31 * result + Arrays.hashCode(attenuationDurationsInMinutes);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExposureInformation{" +
|
||||
"date=" + getDate() +
|
||||
", durationMinutes=" + durationMinutes +
|
||||
", attenuationValue=" + attenuationValue +
|
||||
", transmissionRiskLevel=" + transmissionRiskLevel +
|
||||
", totalRiskScore=" + totalRiskScore +
|
||||
", attenuationDurationsInMinutes=" + Arrays.toString(attenuationDurationsInMinutes) +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class ExposureInformationBuilder {
|
||||
private long dateMillisSinceEpoch;
|
||||
private int durationMinutes;
|
||||
private int attenuationValue;
|
||||
@RiskLevel
|
||||
private int transmissionRiskLevel;
|
||||
private int totalRiskScore;
|
||||
private int[] attenuationDurations = new int[]{0, 0};
|
||||
|
||||
public ExposureInformationBuilder setDateMillisSinceEpoch(long dateMillisSinceEpoch) {
|
||||
this.dateMillisSinceEpoch = dateMillisSinceEpoch;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureInformationBuilder setDurationMinutes(int durationMinutes) {
|
||||
this.durationMinutes = durationMinutes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureInformationBuilder setAttenuationValue(int attenuationValue) {
|
||||
this.attenuationValue = attenuationValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureInformationBuilder setTransmissionRiskLevel(@RiskLevel int transmissionRiskLevel) {
|
||||
this.transmissionRiskLevel = transmissionRiskLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureInformationBuilder setTotalRiskScore(int totalRiskScore) {
|
||||
this.totalRiskScore = totalRiskScore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureInformationBuilder setAttenuationDurations(int[] attenuationDurations) {
|
||||
this.attenuationDurations = Arrays.copyOf(attenuationDurations, attenuationDurations.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureInformation build() {
|
||||
return new ExposureInformation(dateMillisSinceEpoch, durationMinutes, attenuationValue, transmissionRiskLevel, totalRiskScore, attenuationDurations);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<ExposureInformation> CREATOR = new AutoCreator<>(ExposureInformation.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.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 com.google.android.gms.common.api.Api;
|
||||
import com.google.android.gms.common.api.HasApiKey;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Interface for contact tracing APIs.
|
||||
*/
|
||||
@PublicApi
|
||||
public interface ExposureNotificationClient extends HasApiKey<Api.ApiOptions.NoOptions> {
|
||||
/**
|
||||
* Activity action which shows the exposure notification settings screen.
|
||||
*/
|
||||
String ACTION_EXPOSURE_NOTIFICATION_SETTINGS = "com.google.android.gms.settings.EXPOSURE_NOTIFICATION_SETTINGS";
|
||||
/**
|
||||
* Action which will be invoked via a BroadcastReceiver as a callback when matching has finished and no matches were found.
|
||||
* Also see {@link #EXTRA_TOKEN}, which will be included in this broadcast.
|
||||
*/
|
||||
String ACTION_EXPOSURE_NOT_FOUND = "com.google.android.gms.exposurenotification.ACTION_EXPOSURE_NOT_FOUND";
|
||||
/**
|
||||
* Action which will be invoked via a BroadcastReceiver as a callback when the user has an updated exposure status.
|
||||
* Also see {@link #EXTRA_EXPOSURE_SUMMARY} and {@link #EXTRA_TOKEN}, which will be included in this broadcast.
|
||||
*/
|
||||
String ACTION_EXPOSURE_STATE_UPDATED = "com.google.android.gms.exposurenotification.ACTION_EXPOSURE_STATE_UPDATED";
|
||||
/**
|
||||
* Action broadcast to a client application if {@link #requestPreAuthorizedTemporaryExposureKeyRelease()} has been authorized and the user has unlocked their phone, granting release of their keys after a positive diagnosis.
|
||||
*
|
||||
* This action will include an {@link java.util.ArrayList} of {@link TemporaryExposureKey}s keyed by {@link #EXTRA_TEMPORARY_EXPOSURE_KEY_LIST}.
|
||||
*/
|
||||
String ACTION_PRE_AUTHORIZE_RELEASE_PHONE_UNLOCKED = "com.google.android.gms.exposurenotification.ACTION_PRE_AUTHORIZE_RELEASE_PHONE_UNLOCKED";
|
||||
/**
|
||||
* Action which will be invoked via a BroadcastReceiver when the user modifies the state of exposure notifications via the Google Settings page.
|
||||
* {@link #EXTRA_SERVICE_STATE} will be included as part of this broadcast.
|
||||
*/
|
||||
String ACTION_SERVICE_STATE_UPDATED = "com.google.android.gms.exposurenotification.ACTION_SERVICE_STATE_UPDATED";
|
||||
/**
|
||||
* Extra attached to the {@link #ACTION_EXPOSURE_STATE_UPDATED} broadcast, giving a summary of the exposure details detected.
|
||||
* Also see {@link #getExposureSummary(String)}.
|
||||
*
|
||||
* @deprecated {@link ExposureSummary} is no longer provided when using the {@link #getExposureWindows()} API. Instead, use {@link #getDailySummaries(DailySummariesConfig)}.
|
||||
*/
|
||||
@Deprecated
|
||||
String EXTRA_EXPOSURE_SUMMARY = "com.google.android.gms.exposurenotification.EXTRA_EXPOSURE_SUMMARY";
|
||||
/**
|
||||
* Boolean extra attached to the {@link #ACTION_SERVICE_STATE_UPDATED} broadcast signifying whether the service is enabled or disabled.
|
||||
*/
|
||||
String EXTRA_SERVICE_STATE = "com.google.android.gms.exposurenotification.EXTRA_SERVICE_STATE";
|
||||
/**
|
||||
* Extra included in the {@link #ACTION_PRE_AUTHORIZE_RELEASE_PHONE_UNLOCKED} broadcast, containing an {@link java.util.ArrayList} of {@link TemporaryExposureKey}s.
|
||||
*/
|
||||
String EXTRA_TEMPORARY_EXPOSURE_KEY_LIST = "com.google.android.gms.exposurenotification.EXTRA_TEMPORARY_EXPOSURE_KEY_LIST";
|
||||
/**
|
||||
* Extra attached to the {@link #ACTION_EXPOSURE_STATE_UPDATED} broadcast, providing the token associated with the {@link #provideDiagnosisKeys(DiagnosisKeyFileProvider)} request.
|
||||
*
|
||||
* @deprecated Tokens are no longer used. Instead, prefer using the tokenless versions of {@link #provideDiagnosisKeys(DiagnosisKeyFileProvider)}, {@link #getExposureWindows()}, and {@link #getDailySummaries(DailySummariesConfig)}.
|
||||
*/
|
||||
@Deprecated
|
||||
String EXTRA_TOKEN = "com.google.android.gms.exposurenotification.EXTRA_TOKEN";
|
||||
/**
|
||||
* Token to be used with ExposureWindows API. Must be used with {@link #provideDiagnosisKeys(DiagnosisKeyFileProvider) }request when later using {@link #getExposureWindows()}.
|
||||
*
|
||||
* @deprecated Tokens are no longer used. Instead, prefer using the tokenless versions of {@link #provideDiagnosisKeys(DiagnosisKeyFileProvider)}, {@link #getExposureWindows()}, and {@link #getDailySummaries(DailySummariesConfig)}.
|
||||
*/
|
||||
@Deprecated
|
||||
String TOKEN_A = "TYZWQ32170AXEUVCDW7A";
|
||||
|
||||
/**
|
||||
* Checks whether the device supports Exposure Notification BLE scanning without requiring location to be enabled first.
|
||||
*/
|
||||
boolean deviceSupportsLocationlessScanning();
|
||||
|
||||
/**
|
||||
* Gets {@link CalibrationConfidence} of the current device.
|
||||
*/
|
||||
Task<Integer> getCalibrationConfidence();
|
||||
|
||||
/**
|
||||
* Retrieves the per-day exposure summaries associated with the provided configuration.
|
||||
* <p>
|
||||
* A valid configuration must be provided to compute the summaries.
|
||||
*/
|
||||
Task<List<DailySummary>> getDailySummaries(DailySummariesConfig dailySummariesConfig);
|
||||
|
||||
/**
|
||||
* Retrieves the current {@link DiagnosisKeysDataMapping}.
|
||||
*/
|
||||
Task<DiagnosisKeysDataMapping> getDiagnosisKeysDataMapping();
|
||||
|
||||
/**
|
||||
* Gets detailed information about exposures that have occurred related to the provided token, which should match the token provided in {@link #provideDiagnosisKeys(DiagnosisKeyFileProvider)}.
|
||||
* <p>
|
||||
* When multiple ExposureInformation objects are returned, they can be:
|
||||
* <ul>
|
||||
* <li>Multiple encounters with a single diagnosis key.</li>
|
||||
* <li>Multiple encounters with the same device across key rotation boundaries.</li>
|
||||
* <li>Encounters with multiple devices.</li>
|
||||
* </ul>
|
||||
* Records of calls to this method will be retained and viewable by the user.
|
||||
*
|
||||
* @deprecated When using the ExposureWindow API, use {@link #getExposureWindows()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Task<List<ExposureInformation>> getExposureInformation(String token);
|
||||
|
||||
/**
|
||||
* Gets a summary of the exposure calculation for the token, which should match the token provided in {@link #provideDiagnosisKeys(DiagnosisKeyFileProvider)}.
|
||||
*
|
||||
* @deprecated When using the ExposureWindow API, use {@link #getDailySummaries(DailySummariesConfig)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Task<ExposureSummary> getExposureSummary(String token);
|
||||
|
||||
/**
|
||||
* Retrieves the list of exposure windows corresponding to the TEKs given to {@link #provideDiagnosisKeys(DiagnosisKeyFileProvider)}.
|
||||
* <p>
|
||||
* Long exposures to one TEK are split into windows of up to 30 minutes of scans, so a given TEK may lead to several exposure windows if beacon sightings for it spanned more than 30 minutes. The link between them (the fact that they all correspond to the same TEK) is lost because those windows are shuffled before being returned and the underlying TEKs are not exposed by the API.
|
||||
*/
|
||||
Task<List<ExposureWindow>> getExposureWindows();
|
||||
|
||||
/**
|
||||
* Retrieves the list of exposure windows corresponding to the TEKs given to provideKeys with token=TOKEN_A.
|
||||
* <p>
|
||||
* Long exposures to one TEK are split into windows of up to 30 minutes of scans, so a given TEK may lead to several exposure windows if beacon sightings for it spanned more than 30 minutes. The link between them (the fact that they all correspond to the same TEK) is lost because those windows are shuffled before being returned and the underlying TEKs are not exposed by the API.
|
||||
* <p>
|
||||
* The provided token must be TOKEN_A.
|
||||
*
|
||||
* @deprecated Tokens are no longer used. Instead, prefer using the tokenless version of {@link #getExposureWindows()}.
|
||||
*/
|
||||
@Deprecated
|
||||
Task<List<ExposureWindow>> getExposureWindows(String token);
|
||||
|
||||
/**
|
||||
* Retrieves the associated {@link PackageConfiguration} for the calling package. Note that this value can be null if no configuration was when starting.
|
||||
*/
|
||||
Task<PackageConfiguration> getPackageConfiguration();
|
||||
|
||||
/**
|
||||
* Gets the current Exposure Notification status.
|
||||
*/
|
||||
Task<Set<ExposureNotificationStatus>> getStatus();
|
||||
|
||||
/**
|
||||
* Gets {@link TemporaryExposureKey} history to be stored on the server.
|
||||
* <p>
|
||||
* This should only be done after proper verification is performed on the client side that the user is diagnosed positive. Each key returned will have an unknown transmission risk level, clients should choose an appropriate risk level for these keys before uploading them to the server.
|
||||
* <p>
|
||||
* The keys provided here will only be from previous days; keys will not be released until after they are no longer an active exposure key.
|
||||
* <p>
|
||||
* This shows a user permission dialog for sharing and uploading data to the server.
|
||||
*/
|
||||
Task<List<TemporaryExposureKey>> getTemporaryExposureKeyHistory();
|
||||
|
||||
/**
|
||||
* Gets the current Exposure Notification version.
|
||||
*/
|
||||
Task<Long> getVersion();
|
||||
|
||||
/**
|
||||
* Indicates whether contact tracing is currently running for the requesting app.
|
||||
*/
|
||||
Task<Boolean> isEnabled();
|
||||
|
||||
/**
|
||||
* Provides a list of diagnosis key files for exposure checking. The files are to be synced from the server. Old diagnosis keys (for example older than 14 days), will be ignored.
|
||||
* <p>
|
||||
* Diagnosis keys will be stored and matching will be performed in the near future, after which you’ll receive a broadcast with the {@link #ACTION_EXPOSURE_STATE_UPDATED} action. If no matches are found, you'll receive an {@link #ACTION_EXPOSURE_NOT_FOUND} action.
|
||||
* <p>
|
||||
* The diagnosis key files must be signed appropriately. Results from this request can also be queried at any time via {@link #getExposureWindows()} and {@link #getDailySummaries(DailySummariesConfig)}.
|
||||
* <p>
|
||||
* After the result Task has returned, keyFiles can be deleted.
|
||||
* <p>
|
||||
* Results remain for 14 days.
|
||||
*
|
||||
* @deprecated Prefer the {@link DiagnosisKeyFileProvider} version of this method instead, which scales better when a large number of files are passed at the same time.
|
||||
*/
|
||||
@Deprecated
|
||||
Task<Void> provideDiagnosisKeys(List<File> keyFiles);
|
||||
|
||||
/**
|
||||
* Provides diagnosis key files for exposure checking. The files are to be synced from the server. Old diagnosis keys (for example older than 14 days), will be ignored.
|
||||
* <p>
|
||||
* Diagnosis keys will be stored and matching will be performed in the near future, after which you’ll receive a broadcast with the {@link #ACTION_EXPOSURE_STATE_UPDATED} action. If no matches are found, you'll receive an {@link #ACTION_EXPOSURE_NOT_FOUND} action.
|
||||
* <p>
|
||||
* The diagnosis key files must be signed appropriately. Results from this request can also be queried at any time via {@link #getExposureWindows()} and {@link #getDailySummaries(DailySummariesConfig)}.
|
||||
* <p>
|
||||
* After the result Task has returned, files can be deleted.
|
||||
* <p>
|
||||
* Results remain for 14 days.
|
||||
*/
|
||||
Task<Void> provideDiagnosisKeys(DiagnosisKeyFileProvider provider);
|
||||
|
||||
/**
|
||||
* Provides a list of diagnosis key files for exposure checking. The files are to be synced from the server. Old diagnosis keys (for example older than 14 days), will be ignored.
|
||||
* <p>
|
||||
* Diagnosis keys will be stored and matching will be performed in the near future, after which you’ll receive a broadcast with the {@link #ACTION_EXPOSURE_STATE_UPDATED} action. If no matches are found, you'll receive an {@link #ACTION_EXPOSURE_NOT_FOUND} action.
|
||||
* <p>
|
||||
* The diagnosis key files must be signed appropriately. Exposure configuration options can be provided to tune the matching algorithm. A unique token for this batch can also be provided, which will be used to associate the matches with this request as part of {@link #getExposureSummary(String)} and {@link #getExposureInformation(String)}. Alternatively, the same token can be passed in multiple times to concatenate results.
|
||||
* <p>
|
||||
* After the result Task has returned, keyFiles can be deleted.
|
||||
* <p>
|
||||
* Results for a given token remain for 14 days.
|
||||
*
|
||||
* @deprecated Tokens and configuration are no longer used. Instead, prefer using the tokenless, configuration-less version of {@link #provideDiagnosisKeys(DiagnosisKeyFileProvider)}.
|
||||
*/
|
||||
@Deprecated
|
||||
Task<Void> provideDiagnosisKeys(List<File> keys, ExposureConfiguration configuration, String token);
|
||||
|
||||
/**
|
||||
* Shows a dialog to the user asking for authorization to get {@link TemporaryExposureKey}s in the background.
|
||||
* <p>
|
||||
* If approved, the client application will be able to call {@link #requestPreAuthorizedTemporaryExposureKeyRelease()} one time in the next 5 days to get a list of {@link TemporaryExposureKey}s for a user which has tested positive.
|
||||
*/
|
||||
Task<Void> requestPreAuthorizedTemporaryExposureKeyHistory();
|
||||
|
||||
/**
|
||||
* If consent has previously been requested and granted by the user using {@link #requestPreAuthorizedTemporaryExposureKeyHistory()}, then this method will cause keys to be released to the client application after the screen is unlocked by the user. Keys will be delivered via a broadcast denoted with the {@link #ACTION_PRE_AUTHORIZE_RELEASE_PHONE_UNLOCKED} action.
|
||||
*/
|
||||
Task<Void> requestPreAuthorizedTemporaryExposureKeyRelease ();
|
||||
|
||||
/**
|
||||
* Sets the diagnosis keys data mapping if it wasn't already changed recently.
|
||||
* <p>
|
||||
* If called twice within 7 days, the second call will have no effect and will raise an exception with status code FAILED_RATE_LIMITED.
|
||||
*/
|
||||
Task<Void> setDiagnosisKeysDataMapping(DiagnosisKeysDataMapping diagnosisKeysMetadataMapping);
|
||||
|
||||
/**
|
||||
* Starts BLE broadcasts and scanning based on the defined protocol.
|
||||
* <p>
|
||||
* If not previously started, this shows a user dialog for consent to start exposure detection and get permission.
|
||||
* <p>
|
||||
* Callbacks regarding exposure status will be provided via a BroadcastReceiver. Clients should register a receiver in their AndroidManifest which can handle the following action:
|
||||
* <ul>
|
||||
* <li>{@code com.google.android.gms.exposurenotification.ACTION_EXPOSURE_STATE_UPDATED}</li>
|
||||
* </ul>
|
||||
* This receiver should also be guarded by the {@code com.google.android.gms.nearby.exposurenotification.EXPOSURE_CALLBACK} permission so that other apps are not able to fake this broadcast.
|
||||
*/
|
||||
Task<Void> start();
|
||||
|
||||
/**
|
||||
* Disables advertising and scanning. Contents of the database and keys will remain.
|
||||
* <p>
|
||||
* If the client app has been uninstalled by the user, this will be automatically invoked and the database and keys will be wiped from the device.
|
||||
*/
|
||||
Task<Void> stop();
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* 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.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Detail status for exposure notification service.
|
||||
*/
|
||||
@PublicApi
|
||||
public enum ExposureNotificationStatus {
|
||||
/**
|
||||
* Exposure notification is running.
|
||||
*/
|
||||
ACTIVATED,
|
||||
/**
|
||||
* Exposure notification is not running.
|
||||
*/
|
||||
INACTIVATED,
|
||||
/**
|
||||
* Bluetooth is not enabled.
|
||||
*/
|
||||
BLUETOOTH_DISABLED,
|
||||
/**
|
||||
* Location is not enabled.
|
||||
*/
|
||||
LOCATION_DISABLED,
|
||||
/**
|
||||
* User is not consent for the client.
|
||||
*/
|
||||
NO_CONSENT,
|
||||
/**
|
||||
* The client is not in approved client list.
|
||||
*/
|
||||
NOT_IN_ALLOWLIST,
|
||||
/**
|
||||
* Can't detected the BLE supporting of this device due to bluetooth is not enabled.
|
||||
*/
|
||||
BLUETOOTH_SUPPORT_UNKNOWN,
|
||||
/**
|
||||
* Hardware of this device doesn't support exposure notification.
|
||||
*/
|
||||
HW_NOT_SUPPORT,
|
||||
/**
|
||||
* There is another client running as active client.
|
||||
*/
|
||||
FOCUS_LOST,
|
||||
/**
|
||||
* Device storage is not sufficient for exposure notification.
|
||||
*/
|
||||
LOW_STORAGE,
|
||||
/**
|
||||
* Current status is unknown.
|
||||
*/
|
||||
UNKNOWN,
|
||||
/**
|
||||
* Exposure notification is not supported.
|
||||
*/
|
||||
EN_NOT_SUPPORT,
|
||||
/**
|
||||
* Exposure notification is not supported for current user profile.
|
||||
*/
|
||||
USER_PROFILE_NOT_SUPPORT,
|
||||
@Deprecated
|
||||
NOT_IN_WHITELIST
|
||||
;
|
||||
|
||||
private long flag() {
|
||||
if (this == NOT_IN_WHITELIST) return NOT_IN_ALLOWLIST.flag();
|
||||
return 1 << ordinal();
|
||||
}
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
public static long setToFlags(Set<ExposureNotificationStatus> set) {
|
||||
long res = 0;
|
||||
for (ExposureNotificationStatus status : set) {
|
||||
res |= status.flag();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
public static Set<ExposureNotificationStatus> flagsToSet(long flags) {
|
||||
Set<ExposureNotificationStatus> set = new HashSet<>();
|
||||
for (ExposureNotificationStatus status : values()) {
|
||||
if (status == NOT_IN_WHITELIST) continue;
|
||||
if ((flags & status.flag()) > 0) {
|
||||
set.add(status);
|
||||
if (status == NOT_IN_ALLOWLIST) set.add(NOT_IN_WHITELIST);
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.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 com.google.android.gms.common.api.CommonStatusCodes;
|
||||
|
||||
public class ExposureNotificationStatusCodes extends CommonStatusCodes {
|
||||
public static final int FAILED = 13;
|
||||
public static final int FAILED_ALREADY_STARTED = 39500;
|
||||
public static final int FAILED_NOT_SUPPORTED = 39501;
|
||||
public static final int FAILED_REJECTED_OPT_IN = 39502;
|
||||
public static final int FAILED_SERVICE_DISABLED = 39503;
|
||||
public static final int FAILED_BLUETOOTH_DISABLED = 39504;
|
||||
public static final int FAILED_TEMPORARILY_DISABLED = 39505;
|
||||
public static final int FAILED_DISK_IO = 39506;
|
||||
public static final int FAILED_UNAUTHORIZED = 39507;
|
||||
public static final int FAILED_RATE_LIMITED = 39508;
|
||||
public static final int FAILED_NOT_IN_FOREGROUND = 39509;
|
||||
public static final int FAILED_KEY_RELEASE_NOT_PREAUTHORIZED = 39510;
|
||||
|
||||
public static String getStatusCodeString(final int statusCode) {
|
||||
switch (statusCode) {
|
||||
case FAILED_ALREADY_STARTED:
|
||||
return "FAILED_ALREADY_STARTED";
|
||||
case FAILED_NOT_SUPPORTED:
|
||||
return "FAILED_NOT_SUPPORTED";
|
||||
case FAILED_REJECTED_OPT_IN:
|
||||
return "FAILED_REJECTED_OPT_IN";
|
||||
case FAILED_SERVICE_DISABLED:
|
||||
return "FAILED_SERVICE_DISABLED";
|
||||
case FAILED_BLUETOOTH_DISABLED:
|
||||
return "FAILED_BLUETOOTH_DISABLED";
|
||||
case FAILED_TEMPORARILY_DISABLED:
|
||||
return "FAILED_TEMPORARILY_DISABLED";
|
||||
case FAILED_DISK_IO:
|
||||
return "FAILED_DISK_IO";
|
||||
case FAILED_UNAUTHORIZED:
|
||||
return "FAILED_UNAUTHORIZED";
|
||||
case FAILED_RATE_LIMITED:
|
||||
return "FAILED_RATE_LIMITED";
|
||||
case FAILED_NOT_IN_FOREGROUND:
|
||||
return "FAILED_NOT_IN_FOREGROUND";
|
||||
case FAILED_KEY_RELEASE_NOT_PREAUTHORIZED:
|
||||
return "FAILED_KEY_RELEASE_NOT_PREAUTHORIZED";
|
||||
default:
|
||||
return CommonStatusCodes.getStatusCodeString(statusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.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.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Deprecated
|
||||
public class ExposureSummary extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
private int daysSinceLastExposure;
|
||||
@Field(2)
|
||||
private int matchedKeyCount;
|
||||
@Field(3)
|
||||
private int maximumRiskScore;
|
||||
@Field(4)
|
||||
private int[] attenuationDurationsInMinutes;
|
||||
@Field(5)
|
||||
private int summationRiskScore;
|
||||
|
||||
private ExposureSummary() {
|
||||
}
|
||||
|
||||
ExposureSummary(int daysSinceLastExposure, int matchedKeyCount, int maximumRiskScore, int[] attenuationDurationsInMinutes, int summationRiskScore) {
|
||||
this.daysSinceLastExposure = daysSinceLastExposure;
|
||||
this.matchedKeyCount = matchedKeyCount;
|
||||
this.maximumRiskScore = maximumRiskScore;
|
||||
this.attenuationDurationsInMinutes = attenuationDurationsInMinutes;
|
||||
this.summationRiskScore = summationRiskScore;
|
||||
}
|
||||
|
||||
public int getDaysSinceLastExposure() {
|
||||
return daysSinceLastExposure;
|
||||
}
|
||||
|
||||
public int getMatchedKeyCount() {
|
||||
return matchedKeyCount;
|
||||
}
|
||||
|
||||
public int getMaximumRiskScore() {
|
||||
return maximumRiskScore;
|
||||
}
|
||||
|
||||
public int[] getAttenuationDurationsInMinutes() {
|
||||
return Arrays.copyOf(attenuationDurationsInMinutes, attenuationDurationsInMinutes.length);
|
||||
}
|
||||
|
||||
public int getSummationRiskScore() {
|
||||
return summationRiskScore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ExposureSummary that = (ExposureSummary) o;
|
||||
|
||||
if (daysSinceLastExposure != that.daysSinceLastExposure) return false;
|
||||
if (matchedKeyCount != that.matchedKeyCount) return false;
|
||||
if (maximumRiskScore != that.maximumRiskScore) return false;
|
||||
if (summationRiskScore != that.summationRiskScore) return false;
|
||||
return Arrays.equals(attenuationDurationsInMinutes, that.attenuationDurationsInMinutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = daysSinceLastExposure;
|
||||
result = 31 * result + matchedKeyCount;
|
||||
result = 31 * result + maximumRiskScore;
|
||||
result = 31 * result + Arrays.hashCode(attenuationDurationsInMinutes);
|
||||
result = 31 * result + summationRiskScore;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ExposureSummary{" +
|
||||
"daysSinceLastExposure=" + daysSinceLastExposure +
|
||||
", matchedKeyCount=" + matchedKeyCount +
|
||||
", maximumRiskScore=" + maximumRiskScore +
|
||||
", attenuationDurationsInMinutes=" + Arrays.toString(attenuationDurationsInMinutes) +
|
||||
", summationRiskScore=" + summationRiskScore +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class ExposureSummaryBuilder {
|
||||
private int daysSinceLastExposure;
|
||||
private int matchedKeyCount;
|
||||
private int maximumRiskScore;
|
||||
private int[] attenuationDurations = new int[]{0, 0, 0};
|
||||
private int summationRiskScore;
|
||||
|
||||
public ExposureSummaryBuilder setDaysSinceLastExposure(int daysSinceLastExposure) {
|
||||
this.daysSinceLastExposure = daysSinceLastExposure;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureSummaryBuilder setMatchedKeyCount(int matchedKeyCount) {
|
||||
this.matchedKeyCount = matchedKeyCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureSummaryBuilder setMaximumRiskScore(int maximumRiskScore) {
|
||||
this.maximumRiskScore = maximumRiskScore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureSummaryBuilder setAttenuationDurations(int[] attenuationDurations) {
|
||||
this.attenuationDurations = Arrays.copyOf(attenuationDurations, attenuationDurations.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureSummaryBuilder setSummationRiskScore(int summationRiskScore) {
|
||||
this.summationRiskScore = summationRiskScore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExposureSummary build() {
|
||||
return new ExposureSummary(daysSinceLastExposure, matchedKeyCount, maximumRiskScore, attenuationDurations, summationRiskScore);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<ExposureSummary> CREATOR = new AutoCreator<>(ExposureSummary.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
* 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 org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A duration of up to 30 minutes during which beacons from a TEK were observed.
|
||||
* <p>
|
||||
* Each {@link ExposureWindow} corresponds to a single TEK, but one TEK can lead to several {@link ExposureWindow} due to random 15-30 minutes cuts. See {@link ExposureNotificationClient#getExposureWindows()} for more info.
|
||||
* <p>
|
||||
* The TEK itself isn't exposed by the API.
|
||||
*/
|
||||
@PublicApi
|
||||
public class ExposureWindow extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
private long dateMillisSinceEpoch;
|
||||
@Field(2)
|
||||
private List<ScanInstance> scanInstances;
|
||||
@Field(3)
|
||||
@ReportType
|
||||
private int reportType;
|
||||
@Field(4)
|
||||
@Infectiousness
|
||||
private int infectiousness;
|
||||
@Field(5)
|
||||
@CalibrationConfidence
|
||||
private int calibrationConfidence;
|
||||
|
||||
private ExposureWindow() {
|
||||
}
|
||||
|
||||
private ExposureWindow(long dateMillisSinceEpoch, List<ScanInstance> scanInstances, int reportType, int infectiousness, int calibrationConfidence) {
|
||||
this.dateMillisSinceEpoch = dateMillisSinceEpoch;
|
||||
this.scanInstances = scanInstances;
|
||||
this.reportType = reportType;
|
||||
this.infectiousness = infectiousness;
|
||||
this.calibrationConfidence = calibrationConfidence;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof ExposureWindow)) return false;
|
||||
|
||||
ExposureWindow that = (ExposureWindow) o;
|
||||
|
||||
if (dateMillisSinceEpoch != that.dateMillisSinceEpoch) return false;
|
||||
if (reportType != that.reportType) return false;
|
||||
if (infectiousness != that.infectiousness) return false;
|
||||
if (calibrationConfidence != that.calibrationConfidence) return false;
|
||||
return scanInstances != null ? scanInstances.equals(that.scanInstances) : that.scanInstances == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Confidence of the BLE Transmit power calibration of the transmitting device.
|
||||
*/
|
||||
@CalibrationConfidence
|
||||
public int getCalibrationConfidence() {
|
||||
return calibrationConfidence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the epoch time in milliseconds the exposure occurred. This will represent the start of a day in UTC.
|
||||
*/
|
||||
public long getDateMillisSinceEpoch() {
|
||||
return dateMillisSinceEpoch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Infectiousness of the TEK that caused this exposure, computed from the days since onset of symptoms using the daysToInfectiousnessMapping.
|
||||
*/
|
||||
@Infectiousness
|
||||
public int getInfectiousness() {
|
||||
return infectiousness;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report Type of the TEK that caused this exposure
|
||||
* <p>
|
||||
* TEKs with no report type set are returned with reportType=CONFIRMED_TEST.
|
||||
* <p>
|
||||
* TEKs with RECURSIVE report type may be dropped because this report type is reserved for future use.
|
||||
* <p>
|
||||
* TEKs with REVOKED or invalid report types do not lead to exposures.
|
||||
*/
|
||||
@ReportType
|
||||
public int getReportType() {
|
||||
return reportType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sightings of this ExposureWindow, time-ordered.
|
||||
* <p>
|
||||
* Each sighting corresponds to a scan (of a few seconds) during which a beacon with the TEK causing this exposure was observed.
|
||||
*/
|
||||
public List<ScanInstance> getScanInstances() {
|
||||
return scanInstances;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (int) (dateMillisSinceEpoch ^ (dateMillisSinceEpoch >>> 32));
|
||||
result = 31 * result + (scanInstances != null ? scanInstances.hashCode() : 0);
|
||||
result = 31 * result + reportType;
|
||||
result = 31 * result + infectiousness;
|
||||
result = 31 * result + calibrationConfidence;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for ExposureWindow.
|
||||
*/
|
||||
public static class Builder {
|
||||
private long dateMillisSinceEpoch;
|
||||
private List<ScanInstance> scanInstances;
|
||||
@ReportType
|
||||
private int reportType;
|
||||
@Infectiousness
|
||||
private int infectiousness;
|
||||
@CalibrationConfidence
|
||||
private int calibrationConfidence;
|
||||
|
||||
public ExposureWindow build() {
|
||||
return new ExposureWindow(dateMillisSinceEpoch, scanInstances, reportType, infectiousness, calibrationConfidence);
|
||||
}
|
||||
|
||||
public Builder setCalibrationConfidence(int calibrationConfidence) {
|
||||
this.calibrationConfidence = calibrationConfidence;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setDateMillisSinceEpoch(long dateMillisSinceEpoch) {
|
||||
this.dateMillisSinceEpoch = dateMillisSinceEpoch;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setInfectiousness(@Infectiousness int infectiousness) {
|
||||
this.infectiousness = infectiousness;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setReportType(@ReportType int reportType) {
|
||||
this.reportType = reportType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setScanInstances(List<ScanInstance> scanInstances) {
|
||||
this.scanInstances = new ArrayList<>(scanInstances);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<ExposureWindow> CREATOR = new AutoCreator<>(ExposureWindow.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Infectiousness defined for an {@link ExposureWindow}.
|
||||
*/
|
||||
@PublicApi
|
||||
public @interface Infectiousness {
|
||||
int NONE = 0;
|
||||
int STANDARD = 1;
|
||||
int HIGH = 2;
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
int VALUES = 3;
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.microg.gms.common.PublicApi;
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
/**
|
||||
* Holds configuration values that can be passed onto the client app after it has finished installing via {@link ExposureNotificationClient#getPackageConfiguration()}.
|
||||
*/
|
||||
@PublicApi
|
||||
public class PackageConfiguration extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
private Bundle values;
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
public PackageConfiguration() {
|
||||
}
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
public PackageConfiguration(Bundle values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public Bundle getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for {@link PackageConfiguration}.
|
||||
*/
|
||||
public static final class PackageConfigurationBuilder {
|
||||
private Bundle values;
|
||||
|
||||
/**
|
||||
* Sets a Bundle containing configuration options.
|
||||
*/
|
||||
public PackageConfigurationBuilder setValues(Bundle values) {
|
||||
this.values = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link PackageConfiguration}.
|
||||
*/
|
||||
public PackageConfiguration build() {
|
||||
return new PackageConfiguration(values);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<PackageConfiguration> CREATOR = new AutoCreator<>(PackageConfiguration.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Report type defined for a {@link TemporaryExposureKey}.
|
||||
*/
|
||||
@PublicApi
|
||||
public @interface ReportType {
|
||||
int UNKNOWN = 0;
|
||||
int CONFIRMED_TEST = 1;
|
||||
int CONFIRMED_CLINICAL_DIAGNOSIS = 2;
|
||||
int SELF_REPORT = 3;
|
||||
int RECURSIVE = 4;
|
||||
int REVOKED = 5;
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
int VALUES = 6;
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.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;
|
||||
|
||||
/**
|
||||
* Risk level defined for an {@link TemporaryExposureKey}.
|
||||
*/
|
||||
@PublicApi
|
||||
public @interface RiskLevel {
|
||||
int RISK_LEVEL_INVALID = 0;
|
||||
int RISK_LEVEL_LOWEST = 1;
|
||||
int RISK_LEVEL_LOW = 2;
|
||||
int RISK_LEVEL_LOW_MEDIUM = 3;
|
||||
int RISK_LEVEL_MEDIUM = 4;
|
||||
int RISK_LEVEL_MEDIUM_HIGH = 5;
|
||||
int RISK_LEVEL_HIGH = 6;
|
||||
int RISK_LEVEL_VERY_HIGH = 7;
|
||||
int RISK_LEVEL_HIGHEST = 8;
|
||||
|
||||
@PublicApi(exclude = true)
|
||||
int VALUES = 9;
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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 org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
/**
|
||||
* Information about the sighting of a TEK within a BLE scan (of a few seconds).
|
||||
* <p>
|
||||
* The TEK itself isn't exposed by the API.
|
||||
*/
|
||||
@PublicApi
|
||||
public class ScanInstance extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
private int typicalAttenuationDb;
|
||||
@Field(2)
|
||||
private int minAttenuationDb;
|
||||
@Field(3)
|
||||
private int secondsSinceLastScan;
|
||||
|
||||
private ScanInstance() {
|
||||
}
|
||||
|
||||
private ScanInstance(int typicalAttenuationDb, int minAttenuationDb, int secondsSinceLastScan) {
|
||||
this.typicalAttenuationDb = typicalAttenuationDb;
|
||||
this.minAttenuationDb = minAttenuationDb;
|
||||
this.secondsSinceLastScan = secondsSinceLastScan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimum attenuation of all of this TEK's beacons received during the scan, in dB.
|
||||
*/
|
||||
public int getMinAttenuationDb() {
|
||||
return minAttenuationDb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seconds elapsed since the previous scan, typically used as a weight.
|
||||
* <p>
|
||||
* Two example uses:
|
||||
* - Summing those values over all sightings of an exposure provides the duration of that exposure.
|
||||
* - Summing those values over all sightings in a given attenuation range and over all exposures recreates the durationAtBuckets of v1.
|
||||
* <p>
|
||||
* Note that the previous scan may not have led to a sighting of that TEK.
|
||||
*/
|
||||
public int getSecondsSinceLastScan() {
|
||||
return secondsSinceLastScan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregation of the attenuations of all of this TEK's beacons received during the scan, in dB. This is most likely to be an average in the dB domain.
|
||||
*/
|
||||
public int getTypicalAttenuationDb() {
|
||||
return typicalAttenuationDb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link ScanInstance}.
|
||||
*/
|
||||
public static class Builder {
|
||||
private int typicalAttenuationDb;
|
||||
private int minAttenuationDb;
|
||||
private int secondsSinceLastScan;
|
||||
|
||||
public ScanInstance build() {
|
||||
return new ScanInstance(typicalAttenuationDb, minAttenuationDb, secondsSinceLastScan);
|
||||
}
|
||||
|
||||
public ScanInstance.Builder setMinAttenuationDb(int minAttenuationDb) {
|
||||
this.minAttenuationDb = minAttenuationDb;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScanInstance.Builder setSecondsSinceLastScan(int secondsSinceLastScan) {
|
||||
this.secondsSinceLastScan = secondsSinceLastScan;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScanInstance.Builder setTypicalAttenuationDb(int typicalAttenuationDb) {
|
||||
this.typicalAttenuationDb = typicalAttenuationDb;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<ScanInstance> CREATOR = new AutoCreator<>(ScanInstance.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.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.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A key generated for advertising over a window of time.
|
||||
*/
|
||||
public class TemporaryExposureKey extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
private byte[] keyData;
|
||||
@Field(2)
|
||||
private int rollingStartIntervalNumber;
|
||||
@Field(3)
|
||||
@RiskLevel
|
||||
private int transmissionRiskLevel;
|
||||
@Field(4)
|
||||
private int rollingPeriod;
|
||||
@Field(5)
|
||||
@ReportType
|
||||
private int reportType;
|
||||
@Field(6)
|
||||
int daysSinceOnsetOfSymptoms;
|
||||
|
||||
/**
|
||||
* The default value for {@link #getDaysSinceOnsetOfSymptoms()}.
|
||||
*
|
||||
* See {@link DiagnosisKeysDataMapping#getDaysSinceOnsetToInfectiousness()} for more information.
|
||||
*/
|
||||
public static final int DAYS_SINCE_ONSET_OF_SYMPTOMS_UNKNOWN = Integer.MAX_VALUE;
|
||||
|
||||
private TemporaryExposureKey() {
|
||||
}
|
||||
|
||||
TemporaryExposureKey(byte[] keyData, int rollingStartIntervalNumber, @RiskLevel int transmissionRiskLevel, int rollingPeriod, @ReportType int reportType, int daysSinceOnsetOfSymptoms) {
|
||||
this.keyData = (keyData == null ? new byte[0] : keyData);
|
||||
this.rollingStartIntervalNumber = rollingStartIntervalNumber;
|
||||
this.transmissionRiskLevel = transmissionRiskLevel;
|
||||
this.rollingPeriod = rollingPeriod;
|
||||
this.reportType = reportType;
|
||||
this.daysSinceOnsetOfSymptoms = daysSinceOnsetOfSymptoms;
|
||||
}
|
||||
|
||||
/**
|
||||
* The randomly generated Temporary Exposure Key information.
|
||||
*/
|
||||
public byte[] getKeyData() {
|
||||
return Arrays.copyOf(keyData, keyData.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* A number describing when a key starts. It is equal to startTimeOfKeySinceEpochInSecs / (60 * 10).
|
||||
*/
|
||||
public int getRollingStartIntervalNumber() {
|
||||
return rollingStartIntervalNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Risk of transmission associated with the person this key came from.
|
||||
*/
|
||||
@RiskLevel
|
||||
public int getTransmissionRiskLevel() {
|
||||
return transmissionRiskLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* A number describing how long a key is valid. It is expressed in increments of 10 minutes (e.g. 144 for 24 hours).
|
||||
*/
|
||||
public int getRollingPeriod() {
|
||||
return rollingPeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of diagnosis associated with a key.
|
||||
*/
|
||||
@ReportType
|
||||
public int getReportType() {
|
||||
return reportType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of days elapsed between symptom onset and the key being used.
|
||||
* <p>
|
||||
* E.g. 2 means the key is 2 days after onset of symptoms.
|
||||
*/
|
||||
public int getDaysSinceOnsetOfSymptoms() {
|
||||
return daysSinceOnsetOfSymptoms;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TemporaryExposureKey that = (TemporaryExposureKey) o;
|
||||
|
||||
if (rollingStartIntervalNumber != that.rollingStartIntervalNumber) return false;
|
||||
if (transmissionRiskLevel != that.transmissionRiskLevel) return false;
|
||||
if (rollingPeriod != that.rollingPeriod) return false;
|
||||
if (reportType != that.reportType) return false;
|
||||
if (daysSinceOnsetOfSymptoms != that.daysSinceOnsetOfSymptoms) return false;
|
||||
return Arrays.equals(keyData, that.keyData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Arrays.hashCode(keyData);
|
||||
result = 31 * result + rollingStartIntervalNumber;
|
||||
result = 31 * result + transmissionRiskLevel;
|
||||
result = 31 * result + rollingPeriod;
|
||||
result = 31 * result + reportType;
|
||||
result = 31 * result + daysSinceOnsetOfSymptoms;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TemporaryExposureKey{" +
|
||||
"keyData=" + Arrays.toString(keyData) +
|
||||
", rollingStartIntervalNumber=" + rollingStartIntervalNumber +
|
||||
", transmissionRiskLevel=" + transmissionRiskLevel +
|
||||
", rollingPeriod=" + rollingPeriod +
|
||||
", reportType=" + reportType +
|
||||
", daysSinceOnsetOfSymptoms=" + daysSinceOnsetOfSymptoms +
|
||||
'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for {@link TemporaryExposureKey}.
|
||||
*/
|
||||
public static class TemporaryExposureKeyBuilder {
|
||||
private byte[] keyData;
|
||||
private int rollingStartIntervalNumber;
|
||||
@RiskLevel
|
||||
private int transmissionRiskLevel;
|
||||
private int rollingPeriod;
|
||||
@ReportType
|
||||
private int reportType;
|
||||
private int daysSinceOnsetOfSymptoms = DAYS_SINCE_ONSET_OF_SYMPTOMS_UNKNOWN;
|
||||
|
||||
public TemporaryExposureKeyBuilder setKeyData(byte[] keyData) {
|
||||
this.keyData = Arrays.copyOf(keyData, keyData.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemporaryExposureKeyBuilder setRollingStartIntervalNumber(int rollingStartIntervalNumber) {
|
||||
this.rollingStartIntervalNumber = rollingStartIntervalNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemporaryExposureKeyBuilder setTransmissionRiskLevel(@RiskLevel int transmissionRiskLevel) {
|
||||
this.transmissionRiskLevel = transmissionRiskLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemporaryExposureKeyBuilder setRollingPeriod(int rollingPeriod) {
|
||||
this.rollingPeriod = rollingPeriod;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemporaryExposureKeyBuilder setReportType(@ReportType int reportType) {
|
||||
this.reportType = reportType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemporaryExposureKeyBuilder setDaysSinceOnsetOfSymptoms(int daysSinceOnsetOfSymptoms) {
|
||||
this.daysSinceOnsetOfSymptoms = daysSinceOnsetOfSymptoms;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TemporaryExposureKey build() {
|
||||
return new TemporaryExposureKey(keyData, rollingStartIntervalNumber, transmissionRiskLevel, rollingPeriod, reportType, daysSinceOnsetOfSymptoms);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<TemporaryExposureKey> CREATOR = new AutoCreator<>(TemporaryExposureKey.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Messenger;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class WakeUpService extends Service {
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return new Messenger(new Handler()).getBinder();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetCalibrationConfidenceParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public IIntCallback callback;
|
||||
|
||||
private GetCalibrationConfidenceParams() {}
|
||||
|
||||
public GetCalibrationConfidenceParams(IIntCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<GetCalibrationConfidenceParams> CREATOR = new AutoCreator<>(GetCalibrationConfidenceParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.nearby.exposurenotification.DailySummariesConfig;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetDailySummariesParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public IDailySummaryListCallback callback;
|
||||
@Field(2)
|
||||
public DailySummariesConfig config;
|
||||
|
||||
private GetDailySummariesParams() {}
|
||||
|
||||
public GetDailySummariesParams(IDailySummaryListCallback callback, DailySummariesConfig config) {
|
||||
this.callback = callback;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public static final Creator<GetDailySummariesParams> CREATOR = new AutoCreator<>(GetDailySummariesParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetDiagnosisKeysDataMappingParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public IDiagnosisKeysDataMappingCallback callback;
|
||||
|
||||
private GetDiagnosisKeysDataMappingParams() {}
|
||||
|
||||
public GetDiagnosisKeysDataMappingParams(IDiagnosisKeysDataMappingCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<GetDiagnosisKeysDataMappingParams> CREATOR = new AutoCreator<>(GetDiagnosisKeysDataMappingParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetExposureInformationParams extends AutoSafeParcelable {
|
||||
@Field(2)
|
||||
public IExposureInformationListCallback callback;
|
||||
@Field(3)
|
||||
public String token;
|
||||
|
||||
private GetExposureInformationParams() {}
|
||||
|
||||
public GetExposureInformationParams(IExposureInformationListCallback callback, String token) {
|
||||
this.callback = callback;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public static final Creator<GetExposureInformationParams> CREATOR = new AutoCreator<>(GetExposureInformationParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetExposureSummaryParams extends AutoSafeParcelable {
|
||||
@Field(2)
|
||||
public IExposureSummaryCallback callback;
|
||||
@Field(3)
|
||||
public String token;
|
||||
|
||||
private GetExposureSummaryParams() {}
|
||||
|
||||
public GetExposureSummaryParams(IExposureSummaryCallback callback, String token) {
|
||||
this.callback = callback;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public static final Creator<GetExposureSummaryParams> CREATOR = new AutoCreator<>(GetExposureSummaryParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetExposureWindowsParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public IExposureWindowListCallback callback;
|
||||
@Field(2)
|
||||
public String token;
|
||||
|
||||
private GetExposureWindowsParams() {}
|
||||
|
||||
public GetExposureWindowsParams(IExposureWindowListCallback callback, String token) {
|
||||
this.callback = callback;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public static final Creator<GetExposureWindowsParams> CREATOR = new AutoCreator<>(GetExposureWindowsParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetPackageConfigurationParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public IPackageConfigurationCallback callback;
|
||||
|
||||
private GetPackageConfigurationParams() {}
|
||||
|
||||
public GetPackageConfigurationParams(IPackageConfigurationCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<GetPackageConfigurationParams> CREATOR = new AutoCreator<>(GetPackageConfigurationParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetStatusParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public ILongCallback callback;
|
||||
|
||||
private GetStatusParams() {}
|
||||
|
||||
public GetStatusParams(ILongCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<GetStatusParams> CREATOR = new AutoCreator<>(GetStatusParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetTemporaryExposureKeyHistoryParams extends AutoSafeParcelable {
|
||||
@Field(2)
|
||||
public ITemporaryExposureKeyListCallback callback;
|
||||
|
||||
private GetTemporaryExposureKeyHistoryParams() {}
|
||||
|
||||
public GetTemporaryExposureKeyHistoryParams(ITemporaryExposureKeyListCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<GetTemporaryExposureKeyHistoryParams> CREATOR = new AutoCreator<>(GetTemporaryExposureKeyHistoryParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class GetVersionParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public ILongCallback callback;
|
||||
|
||||
private GetVersionParams() {
|
||||
}
|
||||
|
||||
public GetVersionParams(ILongCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<GetVersionParams> CREATOR = new AutoCreator<>(GetVersionParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class IsEnabledParams extends AutoSafeParcelable {
|
||||
@Field(2)
|
||||
public IBooleanCallback callback;
|
||||
|
||||
private IsEnabledParams() {
|
||||
}
|
||||
|
||||
public IsEnabledParams(IBooleanCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<IsEnabledParams> CREATOR = new AutoCreator<>(IsEnabledParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import android.os.ParcelFileDescriptor;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.gms.common.api.internal.IStatusCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureConfiguration;
|
||||
import com.google.android.gms.nearby.exposurenotification.TemporaryExposureKey;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProvideDiagnosisKeysParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
@Nullable
|
||||
public List<TemporaryExposureKey> keys;
|
||||
@Field(2)
|
||||
public IStatusCallback callback;
|
||||
@Field(3)
|
||||
@Nullable
|
||||
public List<ParcelFileDescriptor> keyFiles;
|
||||
@Field(4)
|
||||
@Nullable
|
||||
public ExposureConfiguration configuration;
|
||||
@Field(5)
|
||||
@Nullable
|
||||
public String token;
|
||||
@Field(6)
|
||||
@Nullable
|
||||
public IDiagnosisKeyFileSupplier keyFileSupplier;
|
||||
|
||||
private ProvideDiagnosisKeysParams() {
|
||||
}
|
||||
|
||||
public ProvideDiagnosisKeysParams(IStatusCallback callback, List<TemporaryExposureKey> keys, List<ParcelFileDescriptor> keyFiles, ExposureConfiguration configuration, String token) {
|
||||
this(callback, keyFiles, configuration, token);
|
||||
this.keys = keys;
|
||||
}
|
||||
|
||||
public ProvideDiagnosisKeysParams(IStatusCallback callback, List<ParcelFileDescriptor> keyFiles, ExposureConfiguration configuration, String token) {
|
||||
this.callback = callback;
|
||||
this.keyFiles = keyFiles;
|
||||
this.configuration = configuration;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public ProvideDiagnosisKeysParams(IStatusCallback callback, IDiagnosisKeyFileSupplier keyFileSupplier) {
|
||||
this.callback = callback;
|
||||
this.keyFileSupplier = keyFileSupplier;
|
||||
}
|
||||
|
||||
public static final Creator<ProvideDiagnosisKeysParams> CREATOR = new AutoCreator<>(ProvideDiagnosisKeysParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.internal.IStatusCallback;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class RequestPreAuthorizedTemporaryExposureKeyHistoryParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public IStatusCallback callback;
|
||||
|
||||
private RequestPreAuthorizedTemporaryExposureKeyHistoryParams() {
|
||||
}
|
||||
|
||||
public RequestPreAuthorizedTemporaryExposureKeyHistoryParams(IStatusCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<RequestPreAuthorizedTemporaryExposureKeyHistoryParams> CREATOR = new AutoCreator<>(RequestPreAuthorizedTemporaryExposureKeyHistoryParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.internal.IStatusCallback;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class RequestPreAuthorizedTemporaryExposureKeyReleaseParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public IStatusCallback callback;
|
||||
|
||||
private RequestPreAuthorizedTemporaryExposureKeyReleaseParams() {
|
||||
}
|
||||
|
||||
public RequestPreAuthorizedTemporaryExposureKeyReleaseParams(IStatusCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<RequestPreAuthorizedTemporaryExposureKeyReleaseParams> CREATOR = new AutoCreator<>(RequestPreAuthorizedTemporaryExposureKeyReleaseParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.internal.IStatusCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.DiagnosisKeysDataMapping;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class SetDiagnosisKeysDataMappingParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public IStatusCallback callback;
|
||||
@Field(2)
|
||||
public DiagnosisKeysDataMapping mapping;
|
||||
|
||||
private SetDiagnosisKeysDataMappingParams() {}
|
||||
|
||||
public SetDiagnosisKeysDataMappingParams(IStatusCallback callback, DiagnosisKeysDataMapping mapping) {
|
||||
this.callback = callback;
|
||||
this.mapping = mapping;
|
||||
}
|
||||
|
||||
public static final Creator<SetDiagnosisKeysDataMappingParams> CREATOR = new AutoCreator<>(SetDiagnosisKeysDataMappingParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.internal.IStatusCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureConfiguration;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class StartParams extends AutoSafeParcelable {
|
||||
@Field(3)
|
||||
public IStatusCallback callback;
|
||||
@Field(4)
|
||||
public ExposureConfiguration configuration;
|
||||
|
||||
private StartParams() {
|
||||
}
|
||||
|
||||
public StartParams(IStatusCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<StartParams> CREATOR = new AutoCreator<>(StartParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package com.google.android.gms.nearby.exposurenotification.internal;
|
||||
|
||||
import com.google.android.gms.common.api.internal.IStatusCallback;
|
||||
|
||||
import org.microg.safeparcel.AutoSafeParcelable;
|
||||
|
||||
public class StopParams extends AutoSafeParcelable {
|
||||
@Field(1)
|
||||
public IStatusCallback callback;
|
||||
|
||||
private StopParams() {
|
||||
}
|
||||
|
||||
public StopParams(IStatusCallback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public static final Creator<StopParams> CREATOR = new AutoCreator<>(StopParams.class);
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package org.microg.gms.nearby;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetCalibrationConfidenceParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetDailySummariesParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetDiagnosisKeysDataMappingParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetExposureInformationParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetExposureSummaryParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetExposureWindowsParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetPackageConfigurationParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetStatusParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetTemporaryExposureKeyHistoryParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetVersionParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.INearbyExposureNotificationService;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IsEnabledParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.ProvideDiagnosisKeysParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.RequestPreAuthorizedTemporaryExposureKeyHistoryParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.RequestPreAuthorizedTemporaryExposureKeyReleaseParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.SetDiagnosisKeysDataMappingParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.StartParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.StopParams;
|
||||
|
||||
import org.microg.gms.common.GmsClient;
|
||||
import org.microg.gms.common.GmsService;
|
||||
import com.google.android.gms.common.api.internal.ConnectionCallbacks;
|
||||
import com.google.android.gms.common.api.internal.OnConnectionFailedListener;
|
||||
|
||||
public class ExposureNotificationApiClient extends GmsClient<INearbyExposureNotificationService> {
|
||||
public ExposureNotificationApiClient(Context context, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener) {
|
||||
super(context, callbacks, connectionFailedListener, GmsService.NEARBY_EXPOSURE.ACTION);
|
||||
serviceId = GmsService.NEARBY_EXPOSURE.SERVICE_ID;
|
||||
requireMicrog = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected INearbyExposureNotificationService interfaceFromBinder(IBinder binder) {
|
||||
return INearbyExposureNotificationService.Stub.asInterface(binder);
|
||||
}
|
||||
|
||||
public void getVersion(GetVersionParams params) throws RemoteException {
|
||||
getServiceInterface().getVersion(params);
|
||||
}
|
||||
|
||||
public void getCalibrationConfidence(GetCalibrationConfidenceParams params) throws RemoteException {
|
||||
getServiceInterface().getCalibrationConfidence(params);
|
||||
}
|
||||
|
||||
public void start(StartParams params) throws RemoteException {
|
||||
getServiceInterface().start(params);
|
||||
}
|
||||
|
||||
public void stop(StopParams params) throws RemoteException {
|
||||
getServiceInterface().stop(params);
|
||||
}
|
||||
|
||||
public void isEnabled(IsEnabledParams params) throws RemoteException {
|
||||
getServiceInterface().isEnabled(params);
|
||||
}
|
||||
|
||||
public void getTemporaryExposureKeyHistory(GetTemporaryExposureKeyHistoryParams params) throws RemoteException {
|
||||
getServiceInterface().getTemporaryExposureKeyHistory(params);
|
||||
}
|
||||
|
||||
public void provideDiagnosisKeys(ProvideDiagnosisKeysParams params) throws RemoteException {
|
||||
getServiceInterface().provideDiagnosisKeys(params);
|
||||
}
|
||||
|
||||
public void getExposureSummary(GetExposureSummaryParams params) throws RemoteException {
|
||||
getServiceInterface().getExposureSummary(params);
|
||||
}
|
||||
|
||||
public void getExposureInformation(GetExposureInformationParams params) throws RemoteException {
|
||||
getServiceInterface().getExposureInformation(params);
|
||||
}
|
||||
|
||||
public void getExposureWindows(GetExposureWindowsParams params) throws RemoteException {
|
||||
getServiceInterface().getExposureWindows(params);
|
||||
}
|
||||
|
||||
public void getDailySummaries(GetDailySummariesParams params) throws RemoteException {
|
||||
getServiceInterface().getDailySummaries(params);
|
||||
}
|
||||
|
||||
public void setDiagnosisKeysDataMapping(SetDiagnosisKeysDataMappingParams params) throws RemoteException {
|
||||
getServiceInterface().setDiagnosisKeysDataMapping(params);
|
||||
}
|
||||
|
||||
public void getDiagnosisKeysDataMapping(GetDiagnosisKeysDataMappingParams params) throws RemoteException {
|
||||
getServiceInterface().getDiagnosisKeysDataMapping(params);
|
||||
}
|
||||
|
||||
public void getPackageConfiguration(GetPackageConfigurationParams params) throws RemoteException {
|
||||
getServiceInterface().getPackageConfiguration(params);
|
||||
}
|
||||
|
||||
public void getStatus(GetStatusParams params) throws RemoteException {
|
||||
getServiceInterface().getStatus(params);
|
||||
}
|
||||
|
||||
public void requestPreAuthorizedTemporaryExposureKeyHistory(RequestPreAuthorizedTemporaryExposureKeyHistoryParams params) throws RemoteException {
|
||||
getServiceInterface().requestPreAuthorizedTemporaryExposureKeyHistory(params);
|
||||
}
|
||||
|
||||
public void requestPreAuthorizedTemporaryExposureKeyRelease(RequestPreAuthorizedTemporaryExposureKeyReleaseParams params) throws RemoteException {
|
||||
getServiceInterface().requestPreAuthorizedTemporaryExposureKeyRelease(params);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,510 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2020, microG Project Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package org.microg.gms.nearby;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.google.android.gms.common.api.Api;
|
||||
import com.google.android.gms.common.api.ApiException;
|
||||
import com.google.android.gms.common.api.GoogleApi;
|
||||
import com.google.android.gms.common.api.Status;
|
||||
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;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureNotificationClient;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureNotificationStatus;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureSummary;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureWindow;
|
||||
import com.google.android.gms.nearby.exposurenotification.PackageConfiguration;
|
||||
import com.google.android.gms.nearby.exposurenotification.TemporaryExposureKey;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetCalibrationConfidenceParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetDailySummariesParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetDiagnosisKeysDataMappingParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetExposureInformationParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetExposureSummaryParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetExposureWindowsParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetPackageConfigurationParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetStatusParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetTemporaryExposureKeyHistoryParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.GetVersionParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IBooleanCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IDailySummaryListCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IDiagnosisKeyFileSupplier;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IDiagnosisKeysDataMappingCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IExposureInformationListCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IExposureSummaryCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IExposureWindowListCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IIntCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.ILongCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IPackageConfigurationCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.ITemporaryExposureKeyListCallback;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.IsEnabledParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.ProvideDiagnosisKeysParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.RequestPreAuthorizedTemporaryExposureKeyHistoryParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.RequestPreAuthorizedTemporaryExposureKeyReleaseParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.SetDiagnosisKeysDataMappingParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.StartParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.StopParams;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
|
||||
import org.microg.gms.common.api.PendingGoogleApiCall;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoOptions> implements ExposureNotificationClient {
|
||||
private static final Api<Api.ApiOptions.NoOptions> API = new Api<>((options, context, looper, clientSettings, callbacks, connectionFailedListener) -> new ExposureNotificationApiClient(context, callbacks, connectionFailedListener));
|
||||
|
||||
public ExposureNotificationClientImpl(Context context) {
|
||||
super(context, API, Api.ApiOptions.NO_OPTIONS);
|
||||
}
|
||||
|
||||
private static final String TAG = "ENClientImpl";
|
||||
|
||||
@Override
|
||||
public Task<Long> getVersion() {
|
||||
return scheduleTask((PendingGoogleApiCall<Long, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetVersionParams params = new GetVersionParams(new ILongCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, long result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.getVersion(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Integer> getCalibrationConfidence() {
|
||||
return scheduleTask((PendingGoogleApiCall<Integer, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetCalibrationConfidenceParams params = new GetCalibrationConfidenceParams(new IIntCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, int result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.getCalibrationConfidence(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Void> start() {
|
||||
return scheduleTask((PendingGoogleApiCall<Void, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
StartParams params = new StartParams(new IStatusCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(null);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.start(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Void> stop() {
|
||||
return scheduleTask((PendingGoogleApiCall<Void, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
StopParams params = new StopParams(new IStatusCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(null);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.stop(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Boolean> isEnabled() {
|
||||
return scheduleTask((PendingGoogleApiCall<Boolean, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
IsEnabledParams params = new IsEnabledParams(new IBooleanCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, boolean result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.isEnabled(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<List<TemporaryExposureKey>> getTemporaryExposureKeyHistory() {
|
||||
return scheduleTask((PendingGoogleApiCall<List<TemporaryExposureKey>, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetTemporaryExposureKeyHistoryParams params = new GetTemporaryExposureKeyHistoryParams(new ITemporaryExposureKeyListCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, List<TemporaryExposureKey> result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.getTemporaryExposureKeyHistory(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Void> provideDiagnosisKeys(List<File> keyFiles, ExposureConfiguration configuration, String token) {
|
||||
return scheduleTask((PendingGoogleApiCall<Void, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
List<ParcelFileDescriptor> fds = new ArrayList<>(keyFiles.size());
|
||||
for (File kf: keyFiles) {
|
||||
ParcelFileDescriptor fd;
|
||||
try {
|
||||
fd = ParcelFileDescriptor.open(kf, ParcelFileDescriptor.MODE_READ_ONLY);
|
||||
} catch (FileNotFoundException e) {
|
||||
for (ParcelFileDescriptor ofd : fds) {
|
||||
try {
|
||||
ofd.close();
|
||||
} catch (IOException e2) {
|
||||
Log.w(TAG, "Failed to close file", e2);
|
||||
}
|
||||
}
|
||||
completionSource.setException(e);
|
||||
return;
|
||||
}
|
||||
fds.add(fd);
|
||||
}
|
||||
|
||||
ProvideDiagnosisKeysParams params = new ProvideDiagnosisKeysParams(new IStatusCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(null);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
}, fds, configuration, token);
|
||||
try {
|
||||
client.provideDiagnosisKeys(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Void> provideDiagnosisKeys(List<File> keyFiles) {
|
||||
return provideDiagnosisKeys(keyFiles, null, TOKEN_A);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Void> provideDiagnosisKeys(DiagnosisKeyFileProvider provider) {
|
||||
return scheduleTask((PendingGoogleApiCall<Void, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
ProvideDiagnosisKeysParams params = new ProvideDiagnosisKeysParams(new IStatusCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(null);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
}, new IDiagnosisKeyFileSupplier.Stub() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return provider.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelFileDescriptor next() {
|
||||
try {
|
||||
return ParcelFileDescriptor.open(provider.next(), ParcelFileDescriptor.MODE_READ_ONLY);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.provideDiagnosisKeys(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<ExposureSummary> getExposureSummary(String token) {
|
||||
return scheduleTask((PendingGoogleApiCall<ExposureSummary, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetExposureSummaryParams params = new GetExposureSummaryParams(new IExposureSummaryCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, ExposureSummary result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
}, token);
|
||||
try {
|
||||
client.getExposureSummary(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<List<ExposureInformation>> getExposureInformation(String token) {
|
||||
return scheduleTask((PendingGoogleApiCall<List<ExposureInformation>, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetExposureInformationParams params = new GetExposureInformationParams(new IExposureInformationListCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, List<ExposureInformation> result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
}, token);
|
||||
try {
|
||||
client.getExposureInformation(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<List<ExposureWindow>> getExposureWindows(String token) {
|
||||
return scheduleTask((PendingGoogleApiCall<List<ExposureWindow>, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetExposureWindowsParams params = new GetExposureWindowsParams(new IExposureWindowListCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, List<ExposureWindow> result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
}, token);
|
||||
try {
|
||||
client.getExposureWindows(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<List<ExposureWindow>> getExposureWindows() {
|
||||
return getExposureWindows(TOKEN_A);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<List<DailySummary>> getDailySummaries(DailySummariesConfig dailySummariesConfig) {
|
||||
return scheduleTask((PendingGoogleApiCall<List<DailySummary>, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetDailySummariesParams params = new GetDailySummariesParams(new IDailySummaryListCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, List<DailySummary> result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
}, dailySummariesConfig);
|
||||
try {
|
||||
client.getDailySummaries(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Void> setDiagnosisKeysDataMapping(DiagnosisKeysDataMapping diagnosisKeysMetadataMapping) {
|
||||
return scheduleTask((PendingGoogleApiCall<Void, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
SetDiagnosisKeysDataMappingParams params = new SetDiagnosisKeysDataMappingParams(new IStatusCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(null);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
}, diagnosisKeysMetadataMapping);
|
||||
try {
|
||||
client.setDiagnosisKeysDataMapping(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<DiagnosisKeysDataMapping> getDiagnosisKeysDataMapping() {
|
||||
return scheduleTask((PendingGoogleApiCall<DiagnosisKeysDataMapping, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetDiagnosisKeysDataMappingParams params = new GetDiagnosisKeysDataMappingParams(new IDiagnosisKeysDataMappingCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, DiagnosisKeysDataMapping result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.getDiagnosisKeysDataMapping(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<PackageConfiguration> getPackageConfiguration() {
|
||||
return scheduleTask((PendingGoogleApiCall<PackageConfiguration, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetPackageConfigurationParams params = new GetPackageConfigurationParams(new IPackageConfigurationCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, PackageConfiguration result) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.getPackageConfiguration(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Set<ExposureNotificationStatus>> getStatus() {
|
||||
return scheduleTask((PendingGoogleApiCall<Set<ExposureNotificationStatus>, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
GetStatusParams params = new GetStatusParams(new ILongCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status, long flags) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(ExposureNotificationStatus.flagsToSet(flags));
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.getStatus(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Void> requestPreAuthorizedTemporaryExposureKeyHistory() {
|
||||
return scheduleTask((PendingGoogleApiCall<Void, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
RequestPreAuthorizedTemporaryExposureKeyHistoryParams params = new RequestPreAuthorizedTemporaryExposureKeyHistoryParams(new IStatusCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(null);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.requestPreAuthorizedTemporaryExposureKeyHistory(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Void> requestPreAuthorizedTemporaryExposureKeyRelease() {
|
||||
return scheduleTask((PendingGoogleApiCall<Void, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
RequestPreAuthorizedTemporaryExposureKeyReleaseParams params = new RequestPreAuthorizedTemporaryExposureKeyReleaseParams(new IStatusCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status) {
|
||||
if (status.isSuccess()) {
|
||||
completionSource.setResult(null);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.requestPreAuthorizedTemporaryExposureKeyRelease(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deviceSupportsLocationlessScanning() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue