diff --git a/gradle/publish-android.gradle b/gradle/publish-android.gradle new file mode 100644 index 00000000..d41ae07a --- /dev/null +++ b/gradle/publish-android.gradle @@ -0,0 +1,67 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +task androidSourcesJar(type: Jar) { + archiveClassifier.set("sources") + from android.sourceSets.main.java.source +} + +artifacts { + archives androidSourcesJar +} + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + pom { + name = project.name + url = 'https://github.com/microg/GmsCore' + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'microg' + name = 'microG Team' + } + developer { + id = 'mar-v-in' + name = 'Marvin W.' + } + } + scm { + url = 'https://github.com/microg/GmsCore' + connection = 'scm:git:https://github.com/microg/GmsCore.git' + developerConnection = 'scm:git:ssh://github.com/microg/GmsCore.git' + } + } + + from components.release + artifact androidSourcesJar + } + } + if (project.hasProperty('sonatype.username')) { + repositories { + maven { + name = 'sonatype' + url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' + credentials { + username project.getProperty('sonatype.username') + password project.getProperty('sonatype.password') + } + } + } + } + } + if (project.hasProperty('signing.keyId')) { + signing { + sign publishing.publications + } + } +} diff --git a/gradle/publish-java.gradle b/gradle/publish-java.gradle new file mode 100644 index 00000000..2956bf97 --- /dev/null +++ b/gradle/publish-java.gradle @@ -0,0 +1,57 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + pom { + name = project.name + url = 'https://github.com/microg/GmsCore' + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'microg' + name = 'microG Team' + } + developer { + id = 'mar-v-in' + name = 'Marvin W.' + } + } + scm { + url = 'https://github.com/microg/GmsCore' + connection = 'scm:git:https://github.com/microg/GmsCore.git' + developerConnection = 'scm:git:ssh://github.com/microg/GmsCore.git' + } + } + + from components.java + } + } + if (project.hasProperty('sonatype.username')) { + repositories { + maven { + name = 'sonatype' + url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' + credentials { + username project.getProperty('sonatype.username') + password project.getProperty('sonatype.password') + } + } + } + } + } + if (project.hasProperty('signing.keyId')) { + signing { + sign publishing.publications + } + } +} diff --git a/play-services-base-api/build.gradle b/play-services-base-api/build.gradle index 70d9d624..44bb7b0f 100644 --- a/play-services-base-api/build.gradle +++ b/play-services-base-api/build.gradle @@ -15,6 +15,8 @@ */ apply plugin: 'com.android.library' +apply plugin: 'maven-publish' +apply plugin: 'signing' dependencies { api project(':play-services-basement') @@ -38,3 +40,5 @@ android { targetCompatibility = 1.8 } } + +apply from: '../gradle/publish-android.gradle' diff --git a/play-services-base-core-ui/build.gradle b/play-services-base-core-ui/build.gradle index 8abe5ce5..bed6a1a6 100644 --- a/play-services-base-core-ui/build.gradle +++ b/play-services-base-core-ui/build.gradle @@ -7,6 +7,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-android-extensions' +apply plugin: 'maven-publish' +apply plugin: 'signing' dependencies { api project(':play-services-base') @@ -56,3 +58,5 @@ android { targetCompatibility = 1.8 } } + +apply from: '../gradle/publish-android.gradle' diff --git a/play-services-base-core/build.gradle b/play-services-base-core/build.gradle index 3ff54ab1..ef8f393b 100644 --- a/play-services-base-core/build.gradle +++ b/play-services-base-core/build.gradle @@ -4,6 +4,8 @@ */ apply plugin: 'com.android.library' +apply plugin: 'maven-publish' +apply plugin: 'signing' dependencies { api project(':play-services-basement') @@ -27,3 +29,5 @@ android { targetCompatibility = 1.8 } } + +apply from: '../gradle/publish-android.gradle' diff --git a/play-services-base/build.gradle b/play-services-base/build.gradle index 3d47a737..92d371a9 100644 --- a/play-services-base/build.gradle +++ b/play-services-base/build.gradle @@ -15,6 +15,8 @@ */ apply plugin: 'com.android.library' +apply plugin: 'maven-publish' +apply plugin: 'signing' android { compileSdkVersion androidCompileSdk @@ -32,6 +34,8 @@ android { } } +apply from: '../gradle/publish-android.gradle' + dependencies { api project(':play-services-basement') api project(':play-services-tasks') diff --git a/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java b/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java index ea4cfbe6..d6c7ea48 100644 --- a/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java +++ b/play-services-base/src/main/java/org/microg/gms/common/MultiConnectionKeeper.java @@ -122,7 +122,20 @@ public class MultiConnectionKeeper { @SuppressLint("InlinedApi") public void bind() { Log.d(TAG, "Connection(" + actionString + ") : bind()"); - Intent intent = new Intent(actionString).setPackage(GMS_PACKAGE_NAME); + Intent gmsIntent = new Intent(actionString).setPackage(GMS_PACKAGE_NAME); + Intent selfIntent = new Intent(actionString).setPackage(context.getPackageName()); + Intent intent; + if (context.getPackageManager().resolveService(gmsIntent, 0) == null) { + Log.w(TAG, "No GMS service found for " + actionString); + if (context.getPackageManager().resolveService(selfIntent, 0) != null) { + Log.d(TAG, "Found service for "+actionString+" in self package, using it instead"); + intent = selfIntent; + } else { + return; + } + } else { + intent = gmsIntent; + } int flags = Context.BIND_AUTO_CREATE; if (SDK_INT >= ICE_CREAM_SANDWICH) { flags |= Context.BIND_ADJUST_WITH_ACTIVITY; diff --git a/play-services-basement/build.gradle b/play-services-basement/build.gradle index 201ce74e..56c53a9e 100644 --- a/play-services-basement/build.gradle +++ b/play-services-basement/build.gradle @@ -17,6 +17,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' +apply plugin: 'maven-publish' +apply plugin: 'signing' dependencies { api "org.microg:safe-parcel:$safeParcelVersion" @@ -49,3 +51,5 @@ android { targetCompatibility = 1.8 } } + +apply from: '../gradle/publish-android.gradle' diff --git a/play-services-nearby-api/build.gradle b/play-services-nearby-api/build.gradle index 650fe429..9a567128 100644 --- a/play-services-nearby-api/build.gradle +++ b/play-services-nearby-api/build.gradle @@ -4,6 +4,8 @@ */ apply plugin: 'com.android.library' +apply plugin: 'maven-publish' +apply plugin: 'signing' android { compileSdkVersion androidCompileSdk @@ -21,6 +23,8 @@ android { } } +apply from: '../gradle/publish-android.gradle' + dependencies { api project(':play-services-basement') api project(':play-services-base-api') diff --git a/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/PackageConfiguration.aidl b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/PackageConfiguration.aidl new file mode 100644 index 00000000..5b097519 --- /dev/null +++ b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/PackageConfiguration.aidl @@ -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; diff --git a/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/GetPackageConfigurationParams.aidl b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/GetPackageConfigurationParams.aidl new file mode 100644 index 00000000..cc229837 --- /dev/null +++ b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/GetPackageConfigurationParams.aidl @@ -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; diff --git a/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/GetStatusParams.aidl b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/GetStatusParams.aidl new file mode 100644 index 00000000..8230bc53 --- /dev/null +++ b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/GetStatusParams.aidl @@ -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; diff --git a/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/IDiagnosisKeyFileSupplier.aidl b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/IDiagnosisKeyFileSupplier.aidl new file mode 100644 index 00000000..e5498ac8 --- /dev/null +++ b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/IDiagnosisKeyFileSupplier.aidl @@ -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(); +} 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 b5dcfbe8..fad4f590 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 @@ -18,6 +18,8 @@ import com.google.android.gms.nearby.exposurenotification.internal.GetCalibratio 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; interface INearbyExposureNotificationService{ void start(in StartParams params) = 0; @@ -35,4 +37,6 @@ interface INearbyExposureNotificationService{ void getDailySummaries(in GetDailySummariesParams params) = 15; void setDiagnosisKeysDataMapping(in SetDiagnosisKeysDataMappingParams params) = 16; void getDiagnosisKeysDataMapping(in GetDiagnosisKeysDataMappingParams params) = 17; + void getStatus(in GetStatusParams params) = 18; + void getPackageConfiguration(in GetPackageConfigurationParams params) = 19; } diff --git a/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/IPackageConfigurationCallback.aidl b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/IPackageConfigurationCallback.aidl new file mode 100644 index 00000000..1f2b45d4 --- /dev/null +++ b/play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/IPackageConfigurationCallback.aidl @@ -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); +} diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeyFileProvider.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeyFileProvider.java index 621201a0..53801d54 100644 --- a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeyFileProvider.java +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/DiagnosisKeyFileProvider.java @@ -19,13 +19,20 @@ import java.util.List; */ @PublicApi public class DiagnosisKeyFileProvider { + private int index; private List files; public DiagnosisKeyFileProvider(List files) { this.files = new ArrayList<>(files); } - public List getFiles() { - return files; + @PublicApi(exclude = true) + public boolean hasNext() { + return files.size() > index; + } + + @PublicApi(exclude = true) + public File next() { + return files.get(index++); } } diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationStatus.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationStatus.java new file mode 100644 index 00000000..feabbaf9 --- /dev/null +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/ExposureNotificationStatus.java @@ -0,0 +1,98 @@ +/* + * 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_WHITELIST, + /** + * 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 + ; + + private long flag() { + return 1 << ordinal(); + } + + @PublicApi(exclude = true) + public static long setToFlags(Set set) { + long res = 0; + for (ExposureNotificationStatus status : set) { + res |= status.flag(); + } + return res; + } + + @PublicApi(exclude = true) + public static Set flagsToSet(long flags) { + Set set = new HashSet<>(); + for (ExposureNotificationStatus status : values()) { + if ((flags & status.flag()) > 0) { + set.add(status); + } + } + return set; + } +} diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/PackageConfiguration.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/PackageConfiguration.java new file mode 100644 index 00000000..8f699236 --- /dev/null +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/PackageConfiguration.java @@ -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 CREATOR = new AutoCreator<>(PackageConfiguration.class); +} diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/TemporaryExposureKey.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/TemporaryExposureKey.java index 4514c9a4..8c8bc58a 100644 --- a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/TemporaryExposureKey.java +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/TemporaryExposureKey.java @@ -13,6 +13,9 @@ 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; @@ -29,6 +32,11 @@ public class TemporaryExposureKey extends AutoSafeParcelable { @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 = Constants.DAYS_SINCE_ONSET_OF_SYMPTOMS_UNKNOWN; private TemporaryExposureKey() { @@ -43,29 +51,49 @@ public class TemporaryExposureKey extends AutoSafeParcelable { 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; } - int getDaysSinceOnsetOfSymptoms() { + /** + * Number of days elapsed between symptom onset and the key being used. + *

+ * E.g. 2 means the key is 2 days after onset of symptoms. + */ + public int getDaysSinceOnsetOfSymptoms() { return daysSinceOnsetOfSymptoms; } @@ -107,6 +135,9 @@ public class TemporaryExposureKey extends AutoSafeParcelable { '}'; } + /** + * A builder for {@link TemporaryExposureKey}. + */ public static class TemporaryExposureKeyBuilder { private byte[] keyData; private int rollingStartIntervalNumber; diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/GetPackageConfigurationParams.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/GetPackageConfigurationParams.java new file mode 100644 index 00000000..700eaa67 --- /dev/null +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/GetPackageConfigurationParams.java @@ -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 CREATOR = new AutoCreator<>(GetPackageConfigurationParams.class); +} diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/GetStatusParams.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/GetStatusParams.java new file mode 100644 index 00000000..5e6a6cb6 --- /dev/null +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/GetStatusParams.java @@ -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 CREATOR = new AutoCreator<>(GetStatusParams.class); +} diff --git a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/ProvideDiagnosisKeysParams.java b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/ProvideDiagnosisKeysParams.java index f429d712..a38a8c88 100644 --- a/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/ProvideDiagnosisKeysParams.java +++ b/play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/ProvideDiagnosisKeysParams.java @@ -26,6 +26,8 @@ public class ProvideDiagnosisKeysParams extends AutoSafeParcelable { public ExposureConfiguration configuration; @Field(5) public String token; + @Field(6) + public IDiagnosisKeyFileSupplier keyFileSupplier; private ProvideDiagnosisKeysParams() { } @@ -42,5 +44,10 @@ public class ProvideDiagnosisKeysParams extends AutoSafeParcelable { this.token = token; } + public ProvideDiagnosisKeysParams(IStatusCallback callback, IDiagnosisKeyFileSupplier keyFileSupplier) { + this.callback = callback; + this.keyFileSupplier = keyFileSupplier; + } + public static final Creator CREATOR = new AutoCreator<>(ProvideDiagnosisKeysParams.class); } diff --git a/play-services-nearby-core-proto/build.gradle b/play-services-nearby-core-proto/build.gradle index 10577dc3..49acc5fe 100644 --- a/play-services-nearby-core-proto/build.gradle +++ b/play-services-nearby-core-proto/build.gradle @@ -5,6 +5,8 @@ apply plugin: 'com.squareup.wire' apply plugin: 'kotlin' +apply plugin: 'maven-publish' +apply plugin: 'signing' dependencies { implementation "com.squareup.wire:wire-runtime:$wireVersion" @@ -21,3 +23,5 @@ compileKotlin { compileTestKotlin { kotlinOptions.jvmTarget = 1.8 } + +apply from: '../gradle/publish-java.gradle' diff --git a/play-services-nearby-core-ui/build.gradle b/play-services-nearby-core-ui/build.gradle index 8fed8856..df354be7 100644 --- a/play-services-nearby-core-ui/build.gradle +++ b/play-services-nearby-core-ui/build.gradle @@ -7,6 +7,8 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-android-extensions' +apply plugin: 'maven-publish' +apply plugin: 'signing' dependencies { implementation project(':play-services-nearby-core') @@ -17,11 +19,9 @@ dependencies { // AndroidX UI implementation "androidx.multidex:multidex:$multidexVersion" implementation "androidx.appcompat:appcompat:$appcompatVersion" - implementation "androidx.preference:preference:$preferenceVersion" + implementation "androidx.preference:preference-ktx:$preferenceVersion" // Navigation - implementation "androidx.navigation:navigation-fragment:$navigationVersion" - implementation "androidx.navigation:navigation-ui:$navigationVersion" implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion" implementation "androidx.navigation:navigation-ui-ktx:$navigationVersion" @@ -62,3 +62,5 @@ android { jvmTarget = 1.8 } } + +apply from: '../gradle/publish-android.gradle' diff --git a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsAppPreferencesFragment.kt b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsAppPreferencesFragment.kt index 9ce7f3c1..35ce9a44 100644 --- a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsAppPreferencesFragment.kt +++ b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsAppPreferencesFragment.kt @@ -12,6 +12,7 @@ import androidx.core.text.HtmlCompat import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat +import com.google.android.gms.nearby.exposurenotification.ExposureConfiguration import org.json.JSONObject import org.microg.gms.nearby.exposurenotification.ExposureDatabase import org.microg.gms.nearby.exposurenotification.merge @@ -50,6 +51,9 @@ class ExposureNotificationsAppPreferencesFragment : PreferenceFragmentCompat() { updateContent() } + private fun ExposureConfiguration?.orDefault() = this + ?: ExposureConfiguration.ExposureConfigurationBuilder().build() + fun updateContent() { packageName?.let { packageName -> lifecycleScope.launchWhenResumed { @@ -70,7 +74,7 @@ class ExposureNotificationsAppPreferencesFragment : PreferenceFragmentCompat() { getString(R.string.pref_exposure_app_last_report_summary_encounters_no) } else { database.findAllMeasuredExposures(config.first).merge().map { - val riskScore = it.getRiskScore(config.second) + val riskScore = it.getRiskScore(config.second.orDefault()) "· " + getString(R.string.pref_exposure_app_last_report_summary_encounters_line, DateUtils.formatDateRange(requireContext(), it.timestamp, it.timestamp + it.durationInMinutes * 60 * 1000L, DateUtils.FORMAT_SHOW_TIME or DateUtils.FORMAT_SHOW_DATE), riskScore) }.joinToString("
").let { getString(R.string.pref_exposure_app_last_report_summary_encounters_prefix, merged.size) + "
$it
" + getString(R.string.pref_exposure_app_last_report_summary_encounters_suffix) + "" } } diff --git a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsConfirmActivity.kt b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsConfirmActivity.kt index 2b1bdbdb..a6eb168a 100644 --- a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsConfirmActivity.kt +++ b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsConfirmActivity.kt @@ -5,12 +5,15 @@ package org.microg.gms.nearby.core.ui +import android.content.pm.PackageManager +import android.os.Build import android.os.Bundle import android.os.ResultReceiver +import android.view.View import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity -import org.microg.gms.nearby.core.ui.R +import androidx.core.content.ContextCompat import org.microg.gms.nearby.exposurenotification.* import org.microg.gms.ui.getApplicationInfoIfExists @@ -31,12 +34,16 @@ class ExposureNotificationsConfirmActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.exposure_notifications_confirm_activity) val applicationInfo = packageManager.getApplicationInfoIfExists(targetPackageName) + val selfApplicationInfo = packageManager.getApplicationInfoIfExists(packageName) when (action) { CONFIRM_ACTION_START -> { findViewById(android.R.id.title).text = getString(R.string.exposure_confirm_start_title) findViewById(android.R.id.summary).text = getString(R.string.exposure_confirm_start_summary, applicationInfo?.loadLabel(packageManager) ?: targetPackageName) findViewById