0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-12-03 16:27:26 +00:00

Add new fields to TemporaryExposureKey

This commit is contained in:
Christian Grigis 2020-11-09 21:16:25 +01:00 committed by Marvin W
parent 5ef1144131
commit 12905d6621
2 changed files with 41 additions and 2 deletions

View file

@ -8,6 +8,7 @@
package com.google.android.gms.nearby.exposurenotification;
import org.microg.gms.nearby.exposurenotification.Constants;
import org.microg.safeparcel.AutoSafeParcelable;
import java.util.Arrays;
@ -22,15 +23,24 @@ public class TemporaryExposureKey extends AutoSafeParcelable {
private int transmissionRiskLevel;
@Field(4)
private int rollingPeriod;
@Field(5)
@ReportType
private int reportType;
@Field(6)
int daysSinceOnsetOfSymptoms;
public static final int DAYS_SINCE_ONSET_OF_SYMPTOMS_UNKNOWN = Constants.DAYS_SINCE_ONSET_OF_SYMPTOMS_UNKNOWN;
private TemporaryExposureKey() {
}
TemporaryExposureKey(byte[] keyData, int rollingStartIntervalNumber, @RiskLevel int transmissionRiskLevel, int rollingPeriod) {
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;
}
public byte[] getKeyData() {
@ -50,6 +60,15 @@ public class TemporaryExposureKey extends AutoSafeParcelable {
return rollingPeriod;
}
@ReportType
public int getReportType() {
return reportType;
}
int getDaysSinceOnsetOfSymptoms() {
return daysSinceOnsetOfSymptoms;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -60,6 +79,8 @@ public class TemporaryExposureKey extends AutoSafeParcelable {
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);
}
@ -69,6 +90,8 @@ public class TemporaryExposureKey extends AutoSafeParcelable {
result = 31 * result + rollingStartIntervalNumber;
result = 31 * result + transmissionRiskLevel;
result = 31 * result + rollingPeriod;
result = 31 * result + reportType;
result = 31 * result + daysSinceOnsetOfSymptoms;
return result;
}
@ -79,6 +102,8 @@ public class TemporaryExposureKey extends AutoSafeParcelable {
", rollingStartIntervalNumber=" + rollingStartIntervalNumber +
", transmissionRiskLevel=" + transmissionRiskLevel +
", rollingPeriod=" + rollingPeriod +
", reportType=" + reportType +
", daysSinceOnsetOfSymptoms=" + daysSinceOnsetOfSymptoms +
'}';
}
@ -88,6 +113,9 @@ public class TemporaryExposureKey extends AutoSafeParcelable {
@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);
@ -109,8 +137,18 @@ public class TemporaryExposureKey extends AutoSafeParcelable {
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);
return new TemporaryExposureKey(keyData, rollingStartIntervalNumber, transmissionRiskLevel, rollingPeriod, reportType, daysSinceOnsetOfSymptoms);
}
}

View file

@ -14,4 +14,5 @@ public class Constants {
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";
public static final int DAYS_SINCE_ONSET_OF_SYMPTOMS_UNKNOWN = Integer.MAX_VALUE;
}