diff --git a/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/INearbyExposureNotificationService.aidl b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/INearbyExposureNotificationService.aidl index fad4f590..80f7e6ae 100644 --- a/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/INearbyExposureNotificationService.aidl +++ b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/INearbyExposureNotificationService.aidl @@ -20,6 +20,8 @@ import com.google.android.gms.nearby.exposurenotification.internal.SetDiagnosisK 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{ void start(in StartParams params) = 0; @@ -39,4 +41,6 @@ interface INearbyExposureNotificationService{ void getDiagnosisKeysDataMapping(in GetDiagnosisKeysDataMappingParams params) = 17; void getStatus(in GetStatusParams params) = 18; void getPackageConfiguration(in GetPackageConfigurationParams params) = 19; + void requestPreAuthorizedTemporaryExposureKeyHistory(in RequestPreAuthorizedTemporaryExposureKeyHistoryParams params) = 20; + void requestPreAuthorizedTemporaryExposureKeyRelease(in RequestPreAuthorizedTemporaryExposureKeyReleaseParams params) = 21; } diff --git a/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyHistoryParams.aidl b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyHistoryParams.aidl new file mode 100644 index 00000000..49846674 --- /dev/null +++ b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyHistoryParams.aidl @@ -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; diff --git a/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyReleaseParams.aidl b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyReleaseParams.aidl new file mode 100644 index 00000000..21973e29 --- /dev/null +++ b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyReleaseParams.aidl @@ -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; diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyHistoryParams.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyHistoryParams.java new file mode 100644 index 00000000..ebd807bf --- /dev/null +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyHistoryParams.java @@ -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 CREATOR = new AutoCreator<>(RequestPreAuthorizedTemporaryExposureKeyHistoryParams.class); +} diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyReleaseParams.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyReleaseParams.java new file mode 100644 index 00000000..428cd642 --- /dev/null +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyReleaseParams.java @@ -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 CREATOR = new AutoCreator<>(RequestPreAuthorizedTemporaryExposureKeyReleaseParams.class); +} diff --git a/play-services-nearby-api/src/main/java/org/microg/gms/nearby/exposurenotification/Constants.java b/play-services-nearby-api/src/main/java/org/microg/gms/nearby/exposurenotification/Constants.java index b87dbfbe..11d7fdc2 100644 --- a/play-services-nearby-api/src/main/java/org/microg/gms/nearby/exposurenotification/Constants.java +++ b/play-services-nearby-api/src/main/java/org/microg/gms/nearby/exposurenotification/Constants.java @@ -9,9 +9,11 @@ public class Constants { public static final String ACTION_EXPOSURE_NOTIFICATION_SETTINGS = "com.google.android.gms.settings.EXPOSURE_NOTIFICATION_SETTINGS"; public static final String ACTION_EXPOSURE_NOT_FOUND = "com.google.android.gms.exposurenotification.ACTION_EXPOSURE_NOT_FOUND"; public static final String ACTION_EXPOSURE_STATE_UPDATED = "com.google.android.gms.exposurenotification.ACTION_EXPOSURE_STATE_UPDATED"; + public static final String ACTION_PRE_AUTHORIZE_RELEASE_PHONE_UNLOCKED = "com.google.android.gms.exposurenotification.ACTION_PRE_AUTHORIZE_RELEASE_PHONE_UNLOCKED"; public static final String ACTION_SERVICE_STATE_UPDATED = "com.google.android.gms.exposurenotification.ACTION_SERVICE_STATE_UPDATED"; public static final String EXTRA_EXPOSURE_SUMMARY = "com.google.android.gms.exposurenotification.EXTRA_EXPOSURE_SUMMARY"; public static final String EXTRA_SERVICE_STATE = "com.google.android.gms.exposurenotification.EXTRA_SERVICE_STATE"; + public static final String EXTRA_TEMPORARY_EXPOSURE_KEY_LIST = "com.google.android.gms.exposurenotification.EXTRA_TEMPORARY_EXPOSURE_KEY_LIST"; public static final String EXTRA_TOKEN = "com.google.android.gms.exposurenotification.EXTRA_TOKEN"; public static final String TOKEN_A = "TYZWQ32170AXEUVCDW7A"; public static final int DAYS_SINCE_ONSET_OF_SYMPTOMS_UNKNOWN = Integer.MAX_VALUE; diff --git a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt index ad14bf16..43bd8496 100644 --- a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt +++ b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt @@ -634,6 +634,20 @@ class ExposureNotificationServiceImpl(private val context: Context, private val } } + override fun requestPreAuthorizedTemporaryExposureKeyHistory(params: RequestPreAuthorizedTemporaryExposureKeyHistoryParams) { + // TODO: Proper implementation + lifecycleScope.launchSafely { + params.callback.onResult(Status.CANCELED) + } + } + + override fun requestPreAuthorizedTemporaryExposureKeyRelease(params: RequestPreAuthorizedTemporaryExposureKeyReleaseParams) { + // TODO: Proper implementation + lifecycleScope.launchSafely { + params.callback.onResult(Status.CANCELED) + } + } + override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean { if (super.onTransact(code, data, reply, flags)) return true Log.d(TAG, "onTransact [unknown]: $code, $data, $flags") diff --git a/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationClient.java b/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationClient.java index 177295af..6fa55d94 100644 --- a/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationClient.java +++ b/play-services-nearby/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationClient.java @@ -38,6 +38,12 @@ public interface ExposureNotificationClient extends HasApiKey provideDiagnosisKeys(List keys, ExposureConfiguration configuration, String token); + /** + * Shows a dialog to the user asking for authorization to get {@link TemporaryExposureKey}s in the background. + *

+ * 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 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 requestPreAuthorizedTemporaryExposureKeyRelease (); + /** * Sets the diagnosis keys data mapping if it wasn't already changed recently. *

diff --git a/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationApiClient.java b/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationApiClient.java index f8ecba7b..641fda01 100644 --- a/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationApiClient.java +++ b/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationApiClient.java @@ -22,6 +22,8 @@ import com.google.android.gms.nearby.exposurenotification.internal.GetVersionPar 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; @@ -101,4 +103,12 @@ public class ExposureNotificationApiClient extends GmsClient requestPreAuthorizedTemporaryExposureKeyHistory() { + return scheduleTask((PendingGoogleApiCall) (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 requestPreAuthorizedTemporaryExposureKeyRelease() { + return scheduleTask((PendingGoogleApiCall) (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;