mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-11-19 02:29:25 +01:00
Add some methods to client library
This commit is contained in:
parent
14dfd3e794
commit
f2bc5f5baa
@ -20,6 +20,7 @@ public class ExposureNotificationStatusCodes extends CommonStatusCodes {
|
||||
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 String getStatusCodeString(final int statusCode) {
|
||||
switch (statusCode) {
|
||||
@ -39,6 +40,8 @@ public class ExposureNotificationStatusCodes extends CommonStatusCodes {
|
||||
return "FAILED_DISK_IO";
|
||||
case FAILED_UNAUTHORIZED:
|
||||
return "FAILED_UNAUTHORIZED";
|
||||
case FAILED_RATE_LIMITED:
|
||||
return "FAILED_RATE_LIMITED";
|
||||
default:
|
||||
return CommonStatusCodes.getStatusCodeString(statusCode);
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ 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_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_TOKEN = "com.google.android.gms.exposurenotification.EXTRA_TOKEN";
|
||||
public static final String TOKEN_A = "TYZWQ32170AXEUVCDW7A";
|
||||
}
|
||||
|
@ -23,8 +23,15 @@ public interface ExposureNotificationClient extends HasApiKey<Api.ApiOptions.NoO
|
||||
String ACTION_EXPOSURE_NOTIFICATION_SETTINGS = Constants.ACTION_EXPOSURE_NOTIFICATION_SETTINGS;
|
||||
String ACTION_EXPOSURE_NOT_FOUND = Constants.ACTION_EXPOSURE_NOT_FOUND;
|
||||
String ACTION_EXPOSURE_STATE_UPDATED = Constants.ACTION_EXPOSURE_STATE_UPDATED;
|
||||
String ACTION_SERVICE_STATE_UPDATED = Constants.ACTION_SERVICE_STATE_UPDATED;
|
||||
String EXTRA_EXPOSURE_SUMMARY = Constants.EXTRA_EXPOSURE_SUMMARY;
|
||||
String EXTRA_SERVICE_STATE = Constants.EXTRA_SERVICE_STATE;
|
||||
String EXTRA_TOKEN = Constants.EXTRA_TOKEN;
|
||||
String TOKEN_A = Constants.TOKEN_A;
|
||||
|
||||
Task<Long> getVersion();
|
||||
|
||||
Task<Integer> getCalibrationConfidence();
|
||||
|
||||
Task<Void> start();
|
||||
|
||||
@ -39,4 +46,13 @@ public interface ExposureNotificationClient extends HasApiKey<Api.ApiOptions.NoO
|
||||
Task<ExposureSummary> getExposureSummary(String token);
|
||||
|
||||
Task<List<ExposureInformation>> getExposureInformation(String token);
|
||||
|
||||
Task<List<ExposureWindow>> getExposureWindows(String token);
|
||||
Task<List<ExposureWindow>> getExposureWindows();
|
||||
|
||||
Task<List<DailySummary>> getDailySummaries(DailySummariesConfig config);
|
||||
|
||||
Task<Void> setDiagnosisKeysDataMapping(DiagnosisKeysDataMapping mapping);
|
||||
|
||||
Task<DiagnosisKeysDataMapping> getDiagnosisKeysDataMapping();
|
||||
}
|
||||
|
@ -9,12 +9,18 @@ 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.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.SetDiagnosisKeysDataMappingParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.StartParams;
|
||||
import com.google.android.gms.nearby.exposurenotification.internal.StopParams;
|
||||
|
||||
@ -34,6 +40,14 @@ public class ExposureNotificationApiClient extends GmsClient<INearbyExposureNoti
|
||||
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);
|
||||
}
|
||||
@ -61,4 +75,20 @@ public class ExposureNotificationApiClient extends GmsClient<INearbyExposureNoti
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -15,20 +15,35 @@ 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.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.ExposureSummary;
|
||||
import com.google.android.gms.nearby.exposurenotification.ExposureWindow;
|
||||
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.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.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.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.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;
|
||||
@ -50,6 +65,48 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
|
||||
|
||||
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 == Status.SUCCESS) {
|
||||
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 == Status.SUCCESS) {
|
||||
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) -> {
|
||||
@ -216,6 +273,95 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
|
||||
});
|
||||
}
|
||||
|
||||
@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 == Status.SUCCESS) {
|
||||
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 config) {
|
||||
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 == Status.SUCCESS) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
}, config);
|
||||
try {
|
||||
client.getDailySummaries(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task<Void> setDiagnosisKeysDataMapping(DiagnosisKeysDataMapping mapping) {
|
||||
return scheduleTask((PendingGoogleApiCall<Void, ExposureNotificationApiClient>) (client, completionSource) -> {
|
||||
SetDiagnosisKeysDataMappingParams params = new SetDiagnosisKeysDataMappingParams(new IStatusCallback.Stub() {
|
||||
@Override
|
||||
public void onResult(Status status) {
|
||||
if (status == Status.SUCCESS) {
|
||||
completionSource.setResult(null);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
}, mapping);
|
||||
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 == Status.SUCCESS) {
|
||||
completionSource.setResult(result);
|
||||
} else {
|
||||
completionSource.setException(new ApiException(status));
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
client.getDiagnosisKeysDataMapping(params);
|
||||
} catch (Exception e) {
|
||||
completionSource.setException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiKey<Api.ApiOptions.NoOptions> getApiKey() {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user