0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-11-13 06:25:06 +00:00

EN: Add API for API version 1.8

This commit is contained in:
Marvin W 2021-02-21 16:24:22 -06:00
parent 3d2c7e9523
commit 83a150b128
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A
10 changed files with 160 additions and 0 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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")

View file

@ -38,6 +38,12 @@ public interface ExposureNotificationClient extends HasApiKey<Api.ApiOptions.NoO
* Also see {@link #EXTRA_EXPOSURE_SUMMARY} and {@link #EXTRA_TOKEN}, which will be included in this broadcast.
*/
String ACTION_EXPOSURE_STATE_UPDATED = Constants.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 = Constants.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.
@ -55,6 +61,10 @@ public interface ExposureNotificationClient extends HasApiKey<Api.ApiOptions.NoO
* Boolean extra attached to the {@link #ACTION_SERVICE_STATE_UPDATED} broadcast signifying whether the service is enabled or disabled.
*/
String EXTRA_SERVICE_STATE = Constants.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 = Constants.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.
*
@ -211,6 +221,18 @@ public interface ExposureNotificationClient extends HasApiKey<Api.ApiOptions.NoO
@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>

View file

@ -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<INearbyExposureNoti
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);
}
}

View file

@ -51,6 +51,8 @@ import com.google.android.gms.nearby.exposurenotification.internal.IPackageConfi
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;
@ -458,6 +460,48 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
});
}
@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;