From 1b3c2f87d86907d4391f57971eb55eb01fa16e06 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 21 Jan 2021 11:41:07 +0100 Subject: [PATCH 01/33] Fix Android Studio not reading symbols of proto generated classes --- play-services-core-proto/build.gradle | 4 ++++ play-services-nearby-core-proto/build.gradle | 4 ++++ play-services-wearable-proto/build.gradle | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/play-services-core-proto/build.gradle b/play-services-core-proto/build.gradle index 3ae24b599..68f2a91f6 100644 --- a/play-services-core-proto/build.gradle +++ b/play-services-core-proto/build.gradle @@ -16,6 +16,10 @@ wire { } } +sourceSets { + main.java.srcDirs += "$buildDir/generated/source/wire" +} + compileKotlin { kotlinOptions.jvmTarget = 1.8 } diff --git a/play-services-nearby-core-proto/build.gradle b/play-services-nearby-core-proto/build.gradle index ac8889ee1..c99a4c61d 100644 --- a/play-services-nearby-core-proto/build.gradle +++ b/play-services-nearby-core-proto/build.gradle @@ -16,6 +16,10 @@ wire { kotlin {} } +sourceSets { + main.java.srcDirs += "$buildDir/generated/source/wire" +} + compileKotlin { kotlinOptions.jvmTarget = 1.8 } diff --git a/play-services-wearable-proto/build.gradle b/play-services-wearable-proto/build.gradle index 3ae24b599..68f2a91f6 100644 --- a/play-services-wearable-proto/build.gradle +++ b/play-services-wearable-proto/build.gradle @@ -16,6 +16,10 @@ wire { } } +sourceSets { + main.java.srcDirs += "$buildDir/generated/source/wire" +} + compileKotlin { kotlinOptions.jvmTarget = 1.8 } -- GitLab From 2fbe0a09287d169cdcd6bd9c0dde51e29557d332 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 21 Jan 2021 11:41:49 +0100 Subject: [PATCH 02/33] Mapbox: use specialized location layer Less buggy and more performant, but lacks pulsing animation. Fixes #1293 --- .../src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt index 5af3e40fb..133bb7f81 100644 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt +++ b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt @@ -708,6 +708,7 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) val mapContext = MapContext(context) map.locationComponent.apply { activateLocationComponent(LocationComponentActivationOptions.builder(mapContext, it) + .useSpecializedLocationLayer(true) .locationComponentOptions(LocationComponentOptions.builder(mapContext).pulseEnabled(true).build()) .build()) cameraMode = CameraMode.TRACKING -- GitLab From 3d2c7e95237ee6bc8308f57627fb3530f3dbaf85 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 31 Jan 2021 12:13:03 -0600 Subject: [PATCH 03/33] Add DroidGuard service API and client --- play-services-droidguard-api/build.gradle | 35 +++++++ .../src/main/AndroidManifest.xml | 7 ++ .../internal/DroidGuardInitReply.aidl | 3 + .../internal/DroidGuardResultsRequest.aidl | 3 + .../internal/IDroidGuardCallbacks.aidl | 5 + .../internal/IDroidGuardHandle.aidl | 13 +++ .../internal/IDroidGuardService.aidl | 14 +++ .../internal/DroidGuardInitReply.java | 48 ++++++++++ .../internal/DroidGuardResultsRequest.java | 93 +++++++++++++++++++ play-services-droidguard/build.gradle | 42 +++++++++ .../src/main/AndroidManifest.xml | 7 ++ .../gms/droidguard/DroidGuardApiClient.kt | 25 +++++ .../microg/gms/droidguard/DroidGuardClient.kt | 13 +++ .../gms/droidguard/DroidGuardClientImpl.kt | 33 +++++++ .../microg/gms/droidguard/DroidGuardHandle.kt | 54 +++++++++++ settings.gradle | 2 + 16 files changed, 397 insertions(+) create mode 100644 play-services-droidguard-api/build.gradle create mode 100644 play-services-droidguard-api/src/main/AndroidManifest.xml create mode 100644 play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/DroidGuardInitReply.aidl create mode 100644 play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.aidl create mode 100644 play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardCallbacks.aidl create mode 100644 play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardHandle.aidl create mode 100644 play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardService.aidl create mode 100644 play-services-droidguard-api/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardInitReply.java create mode 100644 play-services-droidguard-api/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.java create mode 100644 play-services-droidguard/build.gradle create mode 100644 play-services-droidguard/src/main/AndroidManifest.xml create mode 100644 play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardApiClient.kt create mode 100644 play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardClient.kt create mode 100644 play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardClientImpl.kt create mode 100644 play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardHandle.kt diff --git a/play-services-droidguard-api/build.gradle b/play-services-droidguard-api/build.gradle new file mode 100644 index 000000000..418290876 --- /dev/null +++ b/play-services-droidguard-api/build.gradle @@ -0,0 +1,35 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +apply plugin: 'com.android.library' +apply plugin: 'maven-publish' +apply plugin: 'signing' + +android { + compileSdkVersion androidCompileSdk + buildToolsVersion "$androidBuildVersionTools" + + defaultConfig { + versionName version + minSdkVersion androidMinSdk + targetSdkVersion androidTargetSdk + } + + compileOptions { + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + } +} + +apply from: '../gradle/publish-android.gradle' + +description = 'microG API for play-services-droidguard' + +dependencies { + api project(':play-services-basement') + api project(':play-services-base-api') + + implementation "androidx.annotation:annotation:$annotationVersion" +} diff --git a/play-services-droidguard-api/src/main/AndroidManifest.xml b/play-services-droidguard-api/src/main/AndroidManifest.xml new file mode 100644 index 000000000..30563293b --- /dev/null +++ b/play-services-droidguard-api/src/main/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/DroidGuardInitReply.aidl b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/DroidGuardInitReply.aidl new file mode 100644 index 000000000..48cd159ff --- /dev/null +++ b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/DroidGuardInitReply.aidl @@ -0,0 +1,3 @@ +package com.google.android.gms.droidguard.internal; + +parcelable DroidGuardInitReply; diff --git a/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.aidl b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.aidl new file mode 100644 index 000000000..9fff3a8db --- /dev/null +++ b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.aidl @@ -0,0 +1,3 @@ +package com.google.android.gms.droidguard.internal; + +parcelable DroidGuardResultsRequest; diff --git a/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardCallbacks.aidl b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardCallbacks.aidl new file mode 100644 index 000000000..7e4aa6808 --- /dev/null +++ b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardCallbacks.aidl @@ -0,0 +1,5 @@ +package com.google.android.gms.droidguard.internal; + +interface IDroidGuardCallbacks { + void onResult(in byte[] res); +} diff --git a/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardHandle.aidl b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardHandle.aidl new file mode 100644 index 000000000..649f2fd8a --- /dev/null +++ b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardHandle.aidl @@ -0,0 +1,13 @@ +package com.google.android.gms.droidguard.internal; + +import com.google.android.gms.droidguard.internal.DroidGuardInitReply; +import com.google.android.gms.droidguard.internal.DroidGuardResultsRequest; + +interface IDroidGuardHandle { + void init(String flow) = 0; + DroidGuardInitReply initWithRequest(String flow, in DroidGuardResultsRequest request) = 4; + + byte[] guard(in Map map) = 1; + + void close() = 2; +} diff --git a/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardService.aidl b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardService.aidl new file mode 100644 index 000000000..2e6044537 --- /dev/null +++ b/play-services-droidguard-api/src/main/aidl/com/google/android/gms/droidguard/internal/IDroidGuardService.aidl @@ -0,0 +1,14 @@ +package com.google.android.gms.droidguard.internal; + +import com.google.android.gms.droidguard.internal.IDroidGuardCallbacks; +import com.google.android.gms.droidguard.internal.IDroidGuardHandle; +import com.google.android.gms.droidguard.internal.DroidGuardResultsRequest; + +interface IDroidGuardService { + void guard(IDroidGuardCallbacks callbacks, String flow, in Map map) = 0; + void guardWithRequest(IDroidGuardCallbacks callbacks, String flow, in Map map, in DroidGuardResultsRequest request) = 3; + + IDroidGuardHandle getHandle() = 1; + + int getClientTimeoutMillis() = 2; +} diff --git a/play-services-droidguard-api/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardInitReply.java b/play-services-droidguard-api/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardInitReply.java new file mode 100644 index 000000000..02b93b0d7 --- /dev/null +++ b/play-services-droidguard-api/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardInitReply.java @@ -0,0 +1,48 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.droidguard.internal; + +import android.os.Parcel; +import android.os.ParcelFileDescriptor; +import android.os.Parcelable; + +public class DroidGuardInitReply implements Parcelable { + public ParcelFileDescriptor pfd; + public Parcelable object; + + public DroidGuardInitReply(ParcelFileDescriptor pfd, Parcelable object) { + this.pfd = pfd; + this.object = object; + } + + @Override + public int describeContents() { + return (pfd != null ? Parcelable.CONTENTS_FILE_DESCRIPTOR : 0) | (object != null ? object.describeContents() : 0); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeParcelable(pfd, flags); + dest.writeParcelable(object, flags); + } + + public final static Creator CREATOR = new Creator() { + @Override + public DroidGuardInitReply createFromParcel(Parcel source) { + ParcelFileDescriptor pfd = source.readParcelable(ParcelFileDescriptor.class.getClassLoader()); + Parcelable object = source.readParcelable(getClass().getClassLoader()); + if (pfd != null && object != null) { + return new DroidGuardInitReply(pfd, object); + } + return null; + } + + @Override + public DroidGuardInitReply[] newArray(int size) { + return new DroidGuardInitReply[size]; + } + }; +} diff --git a/play-services-droidguard-api/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.java b/play-services-droidguard-api/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.java new file mode 100644 index 000000000..162a6bfc0 --- /dev/null +++ b/play-services-droidguard-api/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.java @@ -0,0 +1,93 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.droidguard.internal; + +import android.net.Network; +import android.os.Build; +import android.os.Bundle; +import android.os.ParcelFileDescriptor; + +import androidx.annotation.RequiresApi; + +import org.microg.gms.common.Constants; +import org.microg.safeparcel.AutoSafeParcelable; + +public class DroidGuardResultsRequest extends AutoSafeParcelable { + private static final String KEY_APP_ARCHITECTURE = "appArchitecture"; + private static final String KEY_CLIENT_VERSION = "clientVersion"; + private static final String KEY_FD = "fd"; + private static final String KEY_NETWORK_TO_USE = "networkToUse"; + private static final String KEY_TIMEOUT_MS = "timeoutMs"; + public static final String KEY_OPEN_HANDLES = "openHandles"; + + @Field(2) + public Bundle bundle; + + public DroidGuardResultsRequest() { + bundle = new Bundle(); + String arch; + try { + arch = System.getProperty("os.arch"); + } catch (Exception ignored) { + arch = "?"; + } + bundle.putString(KEY_APP_ARCHITECTURE, arch); + setClientVersion(Constants.GMS_VERSION_CODE); + } + + public String getAppArchitecture() { + return bundle.getString(KEY_APP_ARCHITECTURE); + } + + public int getTimeoutMillis() { + return bundle.getInt(KEY_TIMEOUT_MS, 60000); + } + + public DroidGuardResultsRequest setTimeoutMillis(int millis) { + bundle.putInt(KEY_TIMEOUT_MS, millis); + return this; + } + + public int getClientVersion() { + return bundle.getInt(KEY_CLIENT_VERSION); + } + + public DroidGuardResultsRequest setClientVersion(int clientVersion) { + bundle.putInt(KEY_CLIENT_VERSION, clientVersion); + return this; + } + + public ParcelFileDescriptor getFd() { + return bundle.getParcelable(KEY_FD); + } + + public DroidGuardResultsRequest setFd(ParcelFileDescriptor fd) { + bundle.putParcelable(KEY_FD, fd); + return this; + } + + public int getOpenHandles() { + return bundle.getInt(KEY_OPEN_HANDLES); + } + + public DroidGuardResultsRequest setOpenHandles(int openHandles) { + bundle.putInt(KEY_OPEN_HANDLES, openHandles); + return this; + } + + @RequiresApi(api = 21) + public Network getNetworkToUse() { + return bundle.getParcelable(KEY_NETWORK_TO_USE); + } + + @RequiresApi(api = 21) + public DroidGuardResultsRequest setNetworkToUse(Network networkToUse) { + bundle.putParcelable(KEY_NETWORK_TO_USE, networkToUse); + return this; + } + + public static final Creator CREATOR = new AutoCreator<>(DroidGuardResultsRequest.class); +} diff --git a/play-services-droidguard/build.gradle b/play-services-droidguard/build.gradle new file mode 100644 index 000000000..a473f2d5a --- /dev/null +++ b/play-services-droidguard/build.gradle @@ -0,0 +1,42 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'maven-publish' +apply plugin: 'signing' + +android { + compileSdkVersion androidCompileSdk + buildToolsVersion "$androidBuildVersionTools" + + defaultConfig { + versionName version + minSdkVersion androidMinSdk + targetSdkVersion androidTargetSdk + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + compileOptions { + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + } +} + +apply from: '../gradle/publish-android.gradle' + +description = 'microG implementation of play-services-droidguard' + +dependencies { + api project(':play-services-base') + api project(':play-services-droidguard-api') + + implementation "androidx.annotation:annotation:$annotationVersion" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion" +} diff --git a/play-services-droidguard/src/main/AndroidManifest.xml b/play-services-droidguard/src/main/AndroidManifest.xml new file mode 100644 index 000000000..4d4b7873d --- /dev/null +++ b/play-services-droidguard/src/main/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardApiClient.kt b/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardApiClient.kt new file mode 100644 index 000000000..a9aa7a857 --- /dev/null +++ b/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardApiClient.kt @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.droidguard + +import android.content.Context +import android.os.IBinder +import com.google.android.gms.droidguard.internal.IDroidGuardHandle +import com.google.android.gms.droidguard.internal.IDroidGuardService +import org.microg.gms.common.GmsClient +import org.microg.gms.common.GmsService +import org.microg.gms.common.api.ConnectionCallbacks +import org.microg.gms.common.api.OnConnectionFailedListener + +class DroidGuardApiClient(context: Context, connectionCallbacks: ConnectionCallbacks, onConnectionFailedListener: OnConnectionFailedListener) : GmsClient(context, connectionCallbacks, onConnectionFailedListener, GmsService.DROIDGUARD.ACTION) { + init { + serviceId = GmsService.DROIDGUARD.SERVICE_ID + } + + override fun interfaceFromBinder(binder: IBinder): IDroidGuardService = IDroidGuardService.Stub.asInterface(binder) + + fun getHandle() = serviceInterface.handle +} diff --git a/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardClient.kt b/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardClient.kt new file mode 100644 index 000000000..adcaa45b0 --- /dev/null +++ b/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardClient.kt @@ -0,0 +1,13 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.droidguard + +import com.google.android.gms.droidguard.internal.IDroidGuardHandle +import com.google.android.gms.tasks.Task + +interface DroidGuardClient { + fun getHandle(): Task +} diff --git a/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardClientImpl.kt b/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardClientImpl.kt new file mode 100644 index 000000000..49f3fc63d --- /dev/null +++ b/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardClientImpl.kt @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.droidguard + +import android.content.Context +import android.os.Looper +import com.google.android.gms.common.api.Api +import com.google.android.gms.common.api.Api.ApiOptions.NoOptions +import com.google.android.gms.common.api.GoogleApi +import com.google.android.gms.tasks.Task +import org.microg.gms.common.api.ApiClientBuilder +import org.microg.gms.common.api.ApiClientSettings +import org.microg.gms.common.api.ConnectionCallbacks +import org.microg.gms.common.api.OnConnectionFailedListener + +class DroidGuardClientImpl(context: Context) : GoogleApi(context, API), DroidGuardClient { + companion object { + private val API = Api(ApiClientBuilder { _: NoOptions?, context: Context, _: Looper?, _: ApiClientSettings?, callbacks: ConnectionCallbacks, connectionFailedListener: OnConnectionFailedListener -> DroidGuardApiClient(context, callbacks, connectionFailedListener) }) + } + + override fun getHandle(): Task { + return scheduleTask { client: DroidGuardApiClient, completionSource -> + try { + completionSource.setResult(DroidGuardHandle(client.getHandle())) + } catch (e: Exception) { + completionSource.setException(e) + } + } + } +} diff --git a/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardHandle.kt b/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardHandle.kt new file mode 100644 index 000000000..07e4fd39f --- /dev/null +++ b/play-services-droidguard/src/main/kotlin/org/microg/gms/droidguard/DroidGuardHandle.kt @@ -0,0 +1,54 @@ +/* + * SPDX-FileCopyrightText: 2020, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.droidguard + +import com.google.android.gms.droidguard.internal.DroidGuardResultsRequest +import com.google.android.gms.droidguard.internal.IDroidGuardHandle + +class DroidGuardHandle(private val handle: IDroidGuardHandle) { + private var state = 0 + + fun init(flow: String) { + if (state != 0) throw IllegalStateException("init() already called") + try { + handle.initWithRequest(flow, DroidGuardResultsRequest().setOpenHandles(openHandles++)) + state = 1 + } catch (e: Exception) { + state = -1 + throw e + } + } + + fun guard(map: Map): ByteArray { + if (state != 1) throw IllegalStateException("init() must be called before guard()") + try { + return handle.guard(map) + } catch (e: Exception) { + state = -1 + throw e + } + } + + fun close() { + if (state != 1) throw IllegalStateException("init() must be called before close()") + try { + handle.close() + openHandles-- + state = 2 + } catch (e: Exception) { + state = -1 + throw e + } + } + + fun finalize() { + if (state == 1) close() + } + + companion object { + private var openHandles = 0 + } +} diff --git a/settings.gradle b/settings.gradle index 1ed210811..cdbee8601 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,6 +6,7 @@ include ':play-services-appinvite-api' include ':play-services-base-api' include ':play-services-cast-api' include ':play-services-cast-framework-api' +include ':play-services-droidguard-api' include ':play-services-iid-api' include ':play-services-location-api' include ':play-services-nearby-api' @@ -41,6 +42,7 @@ include ':play-services-core' include ':play-services-base' include ':play-services-cast' +include ':play-services-droidguard' include ':play-services-gcm' include ':play-services-iid' include ':play-services-location' -- GitLab From 83a150b1287d0a615b9a725270ba6d7847c20731 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 21 Feb 2021 16:24:22 -0600 Subject: [PATCH 04/33] EN: Add API for API version 1.8 --- .../INearbyExposureNotificationService.aidl | 4 ++ ...izedTemporaryExposureKeyHistoryParams.aidl | 8 ++++ ...izedTemporaryExposureKeyReleaseParams.aidl | 8 ++++ ...izedTemporaryExposureKeyHistoryParams.java | 24 ++++++++++ ...izedTemporaryExposureKeyReleaseParams.java | 24 ++++++++++ .../exposurenotification/Constants.java | 2 + .../ExposureNotificationServiceImpl.kt | 14 ++++++ .../ExposureNotificationClient.java | 22 ++++++++++ .../nearby/ExposureNotificationApiClient.java | 10 +++++ .../ExposureNotificationClientImpl.java | 44 +++++++++++++++++++ 10 files changed, 160 insertions(+) create mode 100644 play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyHistoryParams.aidl create mode 100644 play-services-nearby-api/src/main/aidl/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyReleaseParams.aidl create mode 100644 play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyHistoryParams.java create mode 100644 play-services-nearby-api/src/main/java/com/google/android/gms/nearby/exposurenotification/internal/RequestPreAuthorizedTemporaryExposureKeyReleaseParams.java 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 fad4f5907..80f7e6ae2 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 000000000..498466744 --- /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 000000000..21973e296 --- /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 000000000..ebd807bfa --- /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 000000000..428cd6428 --- /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 b87dbfbe8..11d7fdc2b 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 ad14bf164..43bd8496a 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 177295af4..6fa55d946 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 f8ecba7b6..641fda01f 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; -- GitLab From 412e513afe8e27c4d183c23e05f27ab752ead0b2 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 21 Feb 2021 16:39:12 -0600 Subject: [PATCH 05/33] EN: Implement new versioning scheme of API 1.8 --- .../org/microg/gms/nearby/exposurenotification/Constants.java | 4 ++++ .../exposurenotification/ExposureNotificationServiceImpl.kt | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) 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 11d7fdc2b..5c40b145c 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 @@ -5,6 +5,8 @@ package org.microg.gms.nearby.exposurenotification; +import static org.microg.gms.common.Constants.GMS_VERSION_CODE; + 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"; @@ -17,4 +19,6 @@ public class Constants { 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; + public static final int VERSION = 18; + public static final long VERSION_FULL = ((long)VERSION) * 1000000000L + GMS_VERSION_CODE; } 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 43bd8496a..566a0f9ae 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 @@ -22,7 +22,6 @@ import com.google.android.gms.nearby.exposurenotification.internal.* import kotlinx.coroutines.* import org.json.JSONArray import org.json.JSONObject -import org.microg.gms.common.Constants import org.microg.gms.common.PackageUtils import org.microg.gms.nearby.exposurenotification.Constants.* import org.microg.gms.nearby.exposurenotification.proto.TemporaryExposureKeyExport @@ -96,7 +95,7 @@ class ExposureNotificationServiceImpl(private val context: Context, private val } override fun getVersion(params: GetVersionParams) { - params.callback.onResult(Status.SUCCESS, Constants.GMS_VERSION_CODE.toLong()) + params.callback.onResult(Status.SUCCESS, VERSION_FULL) } override fun getCalibrationConfidence(params: GetCalibrationConfidenceParams) { -- GitLab From 5b50e24636ef4963e0f43316050c4491cadc4d96 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Sat, 20 Feb 2021 18:06:58 +0100 Subject: [PATCH 06/33] EN: Hide legend if no data is to be displayed --- .../org/microg/gms/nearby/core/ui/DotChartView.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt index 9946dc3b6..76e5590d1 100644 --- a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt +++ b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt @@ -181,13 +181,15 @@ class DotChartView : View { fontPaint.getTextBounds(strNoRecords, 0, strNoRecords.length, fontTempRect) canvas.drawText(strNoRecords, (subLeft + perWidth + 4 * d).toFloat(), (subTop + perHeight / 2.0 + fontTempRect.height() / 2.0).toFloat(), fontPaint) - canvas.drawMyRect((subLeft + (perWidth + innerPadding) * 1 + 12 * d + fontTempRect.width()).toFloat(), subTop.toFloat(), perWidth.toFloat(), perHeight.toFloat(), accentColor and 0xffffff) - canvas.drawMyRect((subLeft + (perWidth + innerPadding) * 2 + 12 * d + fontTempRect.width()).toFloat(), subTop.toFloat(), perWidth.toFloat(), perHeight.toFloat(), accentColor and (80 shl 24 or 0xffffff)) - canvas.drawMyRect((subLeft + (perWidth + innerPadding) * 3 + 12 * d + fontTempRect.width()).toFloat(), subTop.toFloat(), perWidth.toFloat(), perHeight.toFloat(), accentColor and (170 shl 24 or 0xffffff)) - canvas.drawMyRect((subLeft + (perWidth + innerPadding) * 4 + 12 * d + fontTempRect.width()).toFloat(), subTop.toFloat(), perWidth.toFloat(), perHeight.toFloat(), accentColor) + if (maxValue >= 0) { + canvas.drawMyRect((subLeft + (perWidth + innerPadding) * 1 + 12 * d + fontTempRect.width()).toFloat(), subTop.toFloat(), perWidth.toFloat(), perHeight.toFloat(), accentColor and 0xffffff) + canvas.drawMyRect((subLeft + (perWidth + innerPadding) * 2 + 12 * d + fontTempRect.width()).toFloat(), subTop.toFloat(), perWidth.toFloat(), perHeight.toFloat(), accentColor and (80 shl 24 or 0xffffff)) + canvas.drawMyRect((subLeft + (perWidth + innerPadding) * 3 + 12 * d + fontTempRect.width()).toFloat(), subTop.toFloat(), perWidth.toFloat(), perHeight.toFloat(), accentColor and (170 shl 24 or 0xffffff)) + canvas.drawMyRect((subLeft + (perWidth + innerPadding) * 4 + 12 * d + fontTempRect.width()).toFloat(), subTop.toFloat(), perWidth.toFloat(), perHeight.toFloat(), accentColor) - val strRecords = context.getString(R.string.pref_exposure_rpis_histogram_legend_records, "0 - $maxValue") - canvas.drawText(strRecords, (subLeft + (perWidth + innerPadding) * 4 + 16 * d + fontTempRect.width() + perWidth).toFloat(), (subTop + perHeight / 2.0 + fontTempRect.height() / 2.0).toFloat(), fontPaint) + val strRecords = context.getString(R.string.pref_exposure_rpis_histogram_legend_records, "0 - $maxValue") + canvas.drawText(strRecords, (subLeft + (perWidth + innerPadding) * 4 + 16 * d + fontTempRect.width() + perWidth).toFloat(), (subTop + perHeight / 2.0 + fontTempRect.height() / 2.0).toFloat(), fontPaint) + } if (focusHour != -1 && Build.VERSION.SDK_INT >= 23) { val floatingColor = context.resolveColor(androidx.appcompat.R.attr.colorBackgroundFloating) ?: 0 -- GitLab From 87465cd1dda13af39bfbe9f3ca11f259458d2820 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Sat, 20 Feb 2021 16:54:17 +0100 Subject: [PATCH 07/33] Add missing method to GoogleApiAvailability --- .../android/gms/common/GoogleApiAvailability.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/play-services-base/src/main/java/com/google/android/gms/common/GoogleApiAvailability.java b/play-services-base/src/main/java/com/google/android/gms/common/GoogleApiAvailability.java index 889cc7f6f..30afec092 100644 --- a/play-services-base/src/main/java/com/google/android/gms/common/GoogleApiAvailability.java +++ b/play-services-base/src/main/java/com/google/android/gms/common/GoogleApiAvailability.java @@ -163,6 +163,19 @@ public class GoogleApiAvailability { return SUCCESS; } + /** + * Verifies that Google Play services is installed and enabled on this device, and that the version installed on + * this device is no older than the one required by this client or the version is not older than the one specified + * in minApkVersion. + * + * @return status code indicating whether there was an error. Can be one of following in + * {@link ConnectionResult}: SUCCESS, SERVICE_MISSING, SERVICE_UPDATING, + * SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID + */ + public int isGooglePlayServicesAvailable(Context context, int minApkVersion) { + return isGooglePlayServicesAvailable(context); + } + /** * Determines whether an error can be resolved via user action. If true, proceed by calling * {@link #getErrorDialog(Activity, int, int)} and showing the dialog. -- GitLab From ecfe3da3f7573e3d66a1ad9c12e8a08bbeae307b Mon Sep 17 00:00:00 2001 From: Marvin W Date: Tue, 9 Mar 2021 22:21:25 +0100 Subject: [PATCH 08/33] Wakeful receivers only handle non-null intents --- .../java/org/microg/gms/checkin/CheckinService.java | 4 +++- .../src/main/java/org/microg/gms/gcm/McsService.java | 2 +- .../kotlin/org/microg/gms/gcm/PushRegisterService.kt | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java index 06d98af2b..125d5ebb3 100644 --- a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java +++ b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java @@ -95,7 +95,9 @@ public class CheckinService extends IntentService { } catch (Exception e) { Log.w(TAG, e); } finally { - WakefulBroadcastReceiver.completeWakefulIntent(intent); + if (intent != null) { + WakefulBroadcastReceiver.completeWakefulIntent(intent); + } schedule(this); stopSelf(); } diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java index e5c6bb03e..55ee3b7a8 100644 --- a/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java +++ b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java @@ -320,7 +320,7 @@ public class McsService extends Service implements Handler.Callback { WakefulBroadcastReceiver.completeWakefulIntent(intent); } else if (connectIntent == null) { connectIntent = intent; - } else { + } else if (intent != null) { WakefulBroadcastReceiver.completeWakefulIntent(intent); } } diff --git a/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt b/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt index 01dd1a581..02fe6f0a2 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt @@ -112,11 +112,12 @@ class PushRegisterService : LifecycleService() { } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - WakefulBroadcastReceiver.completeWakefulIntent(intent) - Log.d(TAG, "onStartCommand: $intent") - lifecycleScope.launchWhenStarted { - if (intent == null) return@launchWhenStarted - handleIntent(intent) + if (intent != null) { + WakefulBroadcastReceiver.completeWakefulIntent(intent) + Log.d(TAG, "onStartCommand: $intent") + lifecycleScope.launchWhenStarted { + handleIntent(intent) + } } return super.onStartCommand(intent, flags, startId) } -- GitLab From 1516af439557ca99a6cd860a36f1528b8decedbd Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 11 Mar 2021 10:14:29 +0100 Subject: [PATCH 09/33] Move EN permission to withNearby flavour --- play-services-core/src/main/AndroidManifest.xml | 4 ---- play-services-core/src/withNearby/AndroidManifest.xml | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 play-services-core/src/withNearby/AndroidManifest.xml diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index 93d8a6c51..ac3b22549 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -57,10 +57,6 @@ android:label="@string/permission_service_writely_label" android:protectionLevel="dangerous" /> - - + + + + -- GitLab From c9e09e97140730ddd3d328b7f19536285f74da71 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 17 Mar 2021 19:21:59 +0100 Subject: [PATCH 10/33] Use Cursor.getColumnIndexOrThrow() --- .../java/org/microg/gms/gcm/GcmDatabase.java | 37 +++++++------------ .../org/microg/gms/people/PeopleManager.java | 2 +- .../wearable/ConfigurationDatabaseHelper.java | 12 +++--- .../gms/wearable/NodeDatabaseHelper.java | 4 +- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java b/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java index bc5240476..ce32d8d3d 100644 --- a/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java +++ b/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java @@ -1,17 +1,6 @@ /* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2016, microG Project Team + * SPDX-License-Identifier: Apache-2.0 */ package org.microg.gms.gcm; @@ -81,13 +70,13 @@ public class GcmDatabase extends SQLiteOpenHelper { public final boolean wakeForDelivery; private App(Cursor cursor) { - packageName = cursor.getString(cursor.getColumnIndex(FIELD_PACKAGE_NAME)); - lastError = cursor.getString(cursor.getColumnIndex(FIELD_LAST_ERROR)); - lastMessageTimestamp = cursor.getLong(cursor.getColumnIndex(FIELD_LAST_MESSAGE_TIMESTAMP)); - totalMessageCount = cursor.getLong(cursor.getColumnIndex(FIELD_TOTAL_MESSAGE_COUNT)); - totalMessageBytes = cursor.getLong(cursor.getColumnIndex(FIELD_TOTAL_MESSAGE_BYTES)); - allowRegister = cursor.getLong(cursor.getColumnIndex(FIELD_ALLOW_REGISTER)) == 1; - wakeForDelivery = cursor.getLong(cursor.getColumnIndex(FIELD_WAKE_FOR_DELIVERY)) == 1; + packageName = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_PACKAGE_NAME)); + lastError = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_LAST_ERROR)); + lastMessageTimestamp = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_LAST_MESSAGE_TIMESTAMP)); + totalMessageCount = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_TOTAL_MESSAGE_COUNT)); + totalMessageBytes = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_TOTAL_MESSAGE_BYTES)); + allowRegister = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_ALLOW_REGISTER)) == 1; + wakeForDelivery = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_WAKE_FOR_DELIVERY)) == 1; } public boolean hasError() { @@ -102,10 +91,10 @@ public class GcmDatabase extends SQLiteOpenHelper { public final String registerId; public Registration(Cursor cursor) { - packageName = cursor.getString(cursor.getColumnIndex(FIELD_PACKAGE_NAME)); - signature = cursor.getString(cursor.getColumnIndex(FIELD_SIGNATURE)); - timestamp = cursor.getLong(cursor.getColumnIndex(FIELD_TIMESTAMP)); - registerId = cursor.getString(cursor.getColumnIndex(FIELD_REGISTER_ID)); + packageName = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_PACKAGE_NAME)); + signature = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_SIGNATURE)); + timestamp = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_TIMESTAMP)); + registerId = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_REGISTER_ID)); } } diff --git a/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java b/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java index 1450fba3a..2fa793147 100644 --- a/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java +++ b/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java @@ -51,7 +51,7 @@ public class PeopleManager { String url = null; if (cursor.moveToNext()) { int idx = cursor.getColumnIndex("avatar"); - if (!cursor.isNull(idx)) url = cursor.getString(idx); + if (idx >= 0 && !cursor.isNull(idx)) url = cursor.getString(idx); } cursor.close(); databaseHelper.close(); diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/ConfigurationDatabaseHelper.java b/play-services-core/src/main/java/org/microg/gms/wearable/ConfigurationDatabaseHelper.java index 01c8a1a8d..4aa4b58b9 100644 --- a/play-services-core/src/main/java/org/microg/gms/wearable/ConfigurationDatabaseHelper.java +++ b/play-services-core/src/main/java/org/microg/gms/wearable/ConfigurationDatabaseHelper.java @@ -49,12 +49,12 @@ public class ConfigurationDatabaseHelper extends SQLiteOpenHelper { } private static ConnectionConfiguration configFromCursor(final Cursor cursor) { - String name = cursor.getString(cursor.getColumnIndex("name")); - String pairedBtAddress = cursor.getString(cursor.getColumnIndex("pairedBtAddress")); - int connectionType = cursor.getInt(cursor.getColumnIndex("connectionType")); - int role = cursor.getInt(cursor.getColumnIndex("role")); - int enabled = cursor.getInt(cursor.getColumnIndex("connectionEnabled")); - String nodeId = cursor.getString(cursor.getColumnIndex("nodeId")); + String name = cursor.getString(cursor.getColumnIndexOrThrow("name")); + String pairedBtAddress = cursor.getString(cursor.getColumnIndexOrThrow("pairedBtAddress")); + int connectionType = cursor.getInt(cursor.getColumnIndexOrThrow("connectionType")); + int role = cursor.getInt(cursor.getColumnIndexOrThrow("role")); + int enabled = cursor.getInt(cursor.getColumnIndexOrThrow("connectionEnabled")); + String nodeId = cursor.getString(cursor.getColumnIndexOrThrow("nodeId")); if (NULL_STRING.equals(name)) name = null; if (NULL_STRING.equals(pairedBtAddress)) pairedBtAddress = null; return new ConnectionConfiguration(name, pairedBtAddress, connectionType, role, enabled > 0, nodeId); diff --git a/play-services-core/src/main/java/org/microg/gms/wearable/NodeDatabaseHelper.java b/play-services-core/src/main/java/org/microg/gms/wearable/NodeDatabaseHelper.java index d0bfe058b..8b86fee19 100644 --- a/play-services-core/src/main/java/org/microg/gms/wearable/NodeDatabaseHelper.java +++ b/play-services-core/src/main/java/org/microg/gms/wearable/NodeDatabaseHelper.java @@ -289,8 +289,8 @@ public class NodeDatabaseHelper extends SQLiteOpenHelper { Cursor status = db.query("assetsReadyStatus", null, "nowReady != markedReady", null, null, null, null); while (status.moveToNext()) { cv = new ContentValues(); - cv.put("assetsPresent", status.getInt(status.getColumnIndex("nowReady"))); - db.update("dataitems", cv, "_id=?", new String[]{Integer.toString(status.getInt(status.getColumnIndex("dataitems_id")))}); + cv.put("assetsPresent", status.getInt(status.getColumnIndexOrThrow("nowReady"))); + db.update("dataitems", cv, "_id=?", new String[]{Integer.toString(status.getInt(status.getColumnIndexOrThrow("dataitems_id")))}); } status.close(); } -- GitLab From ff1f879ab6ffd940aaeaa1bf86640177c77fd880 Mon Sep 17 00:00:00 2001 From: Marcus Hoffmann Date: Mon, 8 Mar 2021 00:46:53 +0100 Subject: [PATCH 11/33] add deeplink to rpi information screen CCTG could use this when interacting with external microG. Instead of directly embedding the fragment through the bottomNavigationBar we can at least jump to the correct target location. Doing this through an implicit deeplink intent seems easiest as an explicit intent adds all the top level nav elements to the backstack (see: https://developer.android.com/guide/navigation/navigation-deep-link). Tested and this works pretty nicely :). --- play-services-core/src/main/AndroidManifest.xml | 7 +++++++ .../src/main/res/navigation/nav_nearby.xml | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index ac3b22549..8747be328 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -448,6 +448,13 @@ android:label="@string/gms_settings_name" android:process=":ui" android:roundIcon="@mipmap/ic_microg_settings"> + + + + + diff --git a/play-services-nearby-core-ui/src/main/res/navigation/nav_nearby.xml b/play-services-nearby-core-ui/src/main/res/navigation/nav_nearby.xml index 8b27a3d40..47e74b857 100644 --- a/play-services-nearby-core-ui/src/main/res/navigation/nav_nearby.xml +++ b/play-services-nearby-core-ui/src/main/res/navigation/nav_nearby.xml @@ -26,7 +26,11 @@ + android:label="@string/pref_exposure_collected_rpis_title"> + + Date: Thu, 18 Mar 2021 01:19:46 +0100 Subject: [PATCH 12/33] Fix typo --- .../src/main/java/org/microg/gms/people/PeopleManager.java | 4 ++-- .../main/java/org/microg/gms/people/PeopleServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java b/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java index 2fa793147..ccc2442a2 100644 --- a/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java +++ b/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java @@ -45,7 +45,7 @@ public class PeopleManager { public static final String USERINFO_URL = "https://www.googleapis.com/oauth2/v1/userinfo"; public static final String REGEX_SEARCH_USER_PHOTO = "https?\\:\\/\\/lh([0-9]*)\\.googleusercontent\\.com/"; - public static File getOwnerAvaterFile(Context context, String accountName, boolean network) { + public static File getOwnerAvatarFile(Context context, String accountName, boolean network) { DatabaseHelper databaseHelper = new DatabaseHelper(context); Cursor cursor = databaseHelper.getOwner(accountName); String url = null; @@ -78,7 +78,7 @@ public class PeopleManager { } public static Bitmap getOwnerAvatarBitmap(Context context, String accountName, boolean network) { - File avaterFile = getOwnerAvaterFile(context, accountName, network); + File avaterFile = getOwnerAvatarFile(context, accountName, network); if (avaterFile == null) return null; return BitmapFactory.decodeFile(avaterFile.getPath()); } diff --git a/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java index a2f100158..752ae928f 100644 --- a/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java +++ b/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java @@ -127,7 +127,7 @@ public class PeopleServiceImpl extends IPeopleService.Stub { extras.putBoolean("rewindable", false); extras.putInt("width", 0); extras.putInt("height", 0); - File avaterFile = PeopleManager.getOwnerAvaterFile(context, account, true); + File avaterFile = PeopleManager.getOwnerAvatarFile(context, account, true); try { ParcelFileDescriptor fileDescriptor = null; if (avaterFile != null) { -- GitLab From 91b0f6893f9848354af7654b3cebc842615bcd7f Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 18 Mar 2021 01:19:54 +0100 Subject: [PATCH 13/33] GCM: Fix confirm dialog in dark theme --- .../org/microg/gms/ui/AskPushPermission.java | 14 ++- .../src/main/res/layout/ask_gcm.xml | 117 +++++++++--------- .../src/main/res/values/strings.xml | 1 + 3 files changed, 71 insertions(+), 61 deletions(-) diff --git a/play-services-core/src/main/java/org/microg/gms/ui/AskPushPermission.java b/play-services-core/src/main/java/org/microg/gms/ui/AskPushPermission.java index 61a77f3ec..f069cb4ec 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/AskPushPermission.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/AskPushPermission.java @@ -4,9 +4,16 @@ import android.app.Activity; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.graphics.Typeface; import android.os.Bundle; import android.os.ResultReceiver; import android.text.Html; +import android.text.Spannable; +import android.text.SpannableString; +import android.text.SpannableStringBuilder; +import android.text.Spanned; +import android.text.SpannedString; +import android.text.style.StyleSpan; import android.view.View; import android.widget.TextView; @@ -58,9 +65,12 @@ public class AskPushPermission extends FragmentActivity { try { PackageManager pm = getPackageManager(); final ApplicationInfo info = pm.getApplicationInfo(packageName, 0); - CharSequence label = pm.getApplicationLabel(info); + String label = pm.getApplicationLabel(info).toString(); + String raw = getString(R.string.gcm_allow_app_popup, label); + SpannableString s = new SpannableString(raw); + s.setSpan(new StyleSpan(Typeface.BOLD), raw.indexOf(label), raw.indexOf(label) + label.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); - ((TextView) findViewById(R.id.permission_message)).setText(Html.fromHtml("Allow " + label + " to register for push notifications?")); + ((TextView) findViewById(R.id.permission_message)).setText(s); findViewById(R.id.permission_allow_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/play-services-core/src/main/res/layout/ask_gcm.xml b/play-services-core/src/main/res/layout/ask_gcm.xml index f07c30cdc..061e1ef80 100644 --- a/play-services-core/src/main/res/layout/ask_gcm.xml +++ b/play-services-core/src/main/res/layout/ask_gcm.xml @@ -14,88 +14,87 @@ limitations under the License. --> - + android:layout_width="match_parent" + android:layout_height="match_parent"> - - - + + + + + - - - - - - - - - - + android:gravity="center" + android:text="@string/gcm_allow_app_popup" + android:textSize="18sp"> + + + + + + android:orientation="vertical"> + + - + diff --git a/play-services-core/src/main/res/values/strings.xml b/play-services-core/src/main/res/values/strings.xml index e7b12dc0b..12ffbc25f 100644 --- a/play-services-core/src/main/res/values/strings.xml +++ b/play-services-core/src/main/res/values/strings.xml @@ -171,6 +171,7 @@ This can take a couple of minutes." Disconnected Connected since %1$s Receive push notifications + Allow %1$s to register for push notifications? Allow registration Allow the app to register for push notifications. -- GitLab From 161c2ffa24725219737d5be9e5b91d279f38c1ed Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 15 Apr 2021 12:06:24 +0200 Subject: [PATCH 14/33] Add Credentials Picker Stub --- README.md | 2 +- .../credentials/CredentialPickerConfig.java | 24 ++- .../api/credentials/CredentialRequest.java | 24 ++- .../gms/auth/api/credentials/HintRequest.java | 167 ++++++++++++++++++ .../api/credentials/IdentityProviders.java | 31 ++++ .../src/main/AndroidManifest.xml | 9 + .../microg/gms/ui/CredentialPickerActivity.kt | 38 ++++ 7 files changed, 280 insertions(+), 15 deletions(-) create mode 100644 play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/HintRequest.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/IdentityProviders.java create mode 100644 play-services-core/src/main/kotlin/org/microg/gms/ui/CredentialPickerActivity.kt diff --git a/README.md b/README.md index 48d7bca1d..ffcefc7b9 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ microG GmsCore is a FLOSS (Free/Libre Open Source Software) framework to allow a License ------- - Copyright 2013-2020 microG Project Team + Copyright 2013-2021 microG Project Team Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/CredentialPickerConfig.java b/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/CredentialPickerConfig.java index 67d66c05b..3a82499fc 100644 --- a/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/CredentialPickerConfig.java +++ b/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/CredentialPickerConfig.java @@ -16,21 +16,21 @@ package com.google.android.gms.auth.api.credentials; +import org.microg.gms.common.PublicApi; import org.microg.safeparcel.AutoSafeParcelable; import org.microg.safeparcel.SafeParceled; +@PublicApi public class CredentialPickerConfig extends AutoSafeParcelable { - @SafeParceled(1000) + @Field(1000) private int versionCode = 1; - @SafeParceled(1) + @Field(1) private boolean showAddAccountButton; - - @SafeParceled(2) + @Field(2) private boolean showCancelButton; - - @SafeParceled(3) + @Field(3) private boolean forNewAccount; private CredentialPickerConfig() { @@ -42,6 +42,10 @@ public class CredentialPickerConfig extends AutoSafeParcelable { this.forNewAccount = forNewAccount; } + /** + * @deprecated It was determined that this method was not useful for developers. + */ + @Deprecated public boolean isForNewAccount() { return forNewAccount; } @@ -54,6 +58,14 @@ public class CredentialPickerConfig extends AutoSafeParcelable { return showCancelButton; } + @Override + public String toString() { + return "CredentialPickerConfig{" + + "showAddAccountButton=" + showAddAccountButton + + ", showCancelButton=" + showCancelButton + + '}'; + } + public class Builder { private boolean showAddAccountButton; private boolean showCancelButton; diff --git a/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/CredentialRequest.java b/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/CredentialRequest.java index 80819c714..253ae355b 100644 --- a/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/CredentialRequest.java +++ b/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/CredentialRequest.java @@ -25,19 +25,16 @@ import org.microg.safeparcel.SafeParceled; */ public class CredentialRequest extends AutoSafeParcelable { - @SafeParceled(1000) + @Field(1000) private int versionCode = 1; - @SafeParceled(1) + @Field(1) private boolean passwordLoginSupported; - - @SafeParceled(2) + @Field(2) private String[] accountTypes; - - @SafeParceled(3) + @Field(3) private CredentialPickerConfig credentialPickerConfig; - - @SafeParceled(4) + @Field(4) private CredentialPickerConfig credentialHintPickerConfig; public CredentialRequest(boolean passwordLoginSupported, String[] accountTypes, CredentialPickerConfig credentialPickerConfig, CredentialPickerConfig credentialHintPickerConfig) { @@ -72,4 +69,15 @@ public class CredentialRequest extends AutoSafeParcelable { } public static final Creator CREATOR = new AutoCreator(CredentialRequest.class); + + public static class Builder { + private boolean passwordLoginSupported; + private String[] accountTypes; + private CredentialPickerConfig credentialPickerConfig; + private CredentialPickerConfig credentialHintPickerConfig; + + public void setAccountTypes(String... accountTypes) { + this.accountTypes = accountTypes.clone(); + } + } } diff --git a/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/HintRequest.java b/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/HintRequest.java new file mode 100644 index 000000000..32341c98b --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/HintRequest.java @@ -0,0 +1,167 @@ +/* + * SPDX-FileCopyrightText: 2021, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.credentials; + +import org.microg.gms.common.PublicApi; +import org.microg.safeparcel.AutoSafeParcelable; + +import java.util.Arrays; + +/** + * Parameters for requesting the display of the hint picker, via {@link CredentalsApi#getHintPickerIntent()}. + * Instances can be created using {@link HintRequest.Builder}. + */ +@PublicApi +public class HintRequest extends AutoSafeParcelable { + @Field(1000) + private int versionCode = 2; + + @Field(1) + private CredentialPickerConfig hintPickerConfig; + @Field(2) + private boolean emailAddressIdentifierSupported; + @Field(3) + private boolean phoneNumberIdentifierSupported; + @Field(4) + private String[] accountTypes; + @Field(5) + private boolean idTokenRequested = true; + @Field(6) + private String serverClientId; + @Field(7) + private String idTokenNonce; + + private HintRequest() { + } + + public HintRequest(CredentialPickerConfig hintPickerConfig, boolean emailAddressIdentifierSupported, boolean phoneNumberIdentifierSupported, String[] accountTypes, boolean idTokenRequested, String serverClientId, String idTokenNonce) { + this.hintPickerConfig = hintPickerConfig; + this.emailAddressIdentifierSupported = emailAddressIdentifierSupported; + this.phoneNumberIdentifierSupported = phoneNumberIdentifierSupported; + this.accountTypes = accountTypes; + this.idTokenRequested = idTokenRequested; + this.serverClientId = serverClientId; + this.idTokenNonce = idTokenNonce; + } + + public String[] getAccountTypes() { + return accountTypes; + } + + public CredentialPickerConfig getHintPickerConfig() { + return hintPickerConfig; + } + + public String getIdTokenNonce() { + return idTokenNonce; + } + + public String getServerClientId() { + return serverClientId; + } + + public boolean isEmailAddressIdentifierSupported() { + return emailAddressIdentifierSupported; + } + + public boolean isPhoneNumberIdentifierSupported() { + return phoneNumberIdentifierSupported; + } + + public boolean isIdTokenRequested() { + return idTokenRequested; + } + + public static final Creator CREATOR = new AutoCreator<>(HintRequest.class); + + @Override + public String toString() { + return "HintRequest{" + + "hintPickerConfig=" + hintPickerConfig + + ", emailAddressIdentifierSupported=" + emailAddressIdentifierSupported + + ", phoneNumberIdentifierSupported=" + phoneNumberIdentifierSupported + + ", accountTypes=" + Arrays.toString(accountTypes) + + ", idTokenRequested=" + idTokenRequested + + ", serverClientId='" + serverClientId + '\'' + + ", idTokenNonce='" + idTokenNonce + '\'' + + '}'; + } + + public static class Builder { + private CredentialPickerConfig hintPickerConfig; + private boolean emailAddressIdentifierSupported; + private boolean phoneNumberIdentifierSupported; + private String[] accountTypes; + private boolean idTokenRequested = true; + private String serverClientId; + private String idTokenNonce; + + /** + * Builds a {@link HintRequest}. + */ + public HintRequest build() { + return new HintRequest(hintPickerConfig, emailAddressIdentifierSupported, phoneNumberIdentifierSupported, accountTypes, idTokenRequested, serverClientId, idTokenNonce); + } + + /** + * Sets the account types (identity providers) that are accepted by this application. + * It is strongly recommended that the strings listed in {@link IdentityProviders} be used for the most common + * identity providers, and strings representing the login domain of the identity provider be used for any + * others which are not listed. + * + * @param accountTypes The list of account types (identity providers) supported by the app. + * typically in the form of the associated login domain for each identity provider. + */ + public void setAccountTypes(String... accountTypes) { + this.accountTypes = accountTypes.clone(); + } + + /** + * Enables returning {@link Credential} hints where the identifier is an email address, intended for use with a password chosen by the user. + */ + public void setEmailAddressIdentifierSupported(boolean emailAddressIdentifierSupported) { + this.emailAddressIdentifierSupported = emailAddressIdentifierSupported; + } + + /** + * Sets the configuration for the hint picker dialog. + */ + public void setHintPickerConfig(CredentialPickerConfig hintPickerConfig) { + this.hintPickerConfig = hintPickerConfig; + } + + /** + * Specify a nonce value that should be included in any generated ID token for this request. + */ + public void setIdTokenNonce(String idTokenNonce) { + this.idTokenNonce = idTokenNonce; + } + + /** + * Specify whether an ID token should be acquired for hints, if available for the selected credential identifier. + * This is enabled by default; disable this if your app does not use ID tokens as part of authentication to decrease latency in retrieving credentials and credential hints. + */ + public void setIdTokenRequested(boolean idTokenRequested) { + this.idTokenRequested = idTokenRequested; + } + + /** + * Enables returning {@link Credential} hints where the identifier is a phone number, intended for use with a password chosen by the user or SMS verification. + */ + public void setPhoneNumberIdentifierSupported(boolean phoneNumberIdentifierSupported) { + this.phoneNumberIdentifierSupported = phoneNumberIdentifierSupported; + } + + /** + * Specify the server client ID for the backend associated with this app. + * If a Google ID token can be generated for a retrieved credential or hint, and the specified server client ID is correctly configured to be associated with the app, then it will be used as the audience of the generated token. + * If a null value is specified, the default audience will be used for the generated ID token. + */ + public void setServerClientId(String serverClientId) { + this.serverClientId = serverClientId; + } + } +} diff --git a/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/IdentityProviders.java b/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/IdentityProviders.java new file mode 100644 index 000000000..72683c7ac --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/auth/api/credentials/IdentityProviders.java @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 2021, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.auth.api.credentials; + +import android.accounts.Account; + +/** + * Identity provider constants for use with {@link CredentialRequest.Builder#setAccountTypes(String...)} + */ +public final class IdentityProviders { + public static final String FACEBOOK = "//www.facebook.com"; + public static final String GOOGLE = "//accounts.google.com"; + public static final String LINKEDIN = "//www.linkedin.com"; + public static final String MICROSOFT = "//login.live.com"; + public static final String PAYPAL = "//www.paypal.com"; + public static final String TWITTER = "//twitter.com"; + public static final String YAHOO = "//login.yahoo.com"; + + /** + * Attempts to translate the account type in the provided account into the string that should be used in the credentials API. + * + * @param account an account on the device. + * @return The identity provider string for use with the Credentials API, or {@code null} if the account type is unknown. + */ + public static String getIdentityProviderForAccount(Account account) { + return null; + } +} diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index 8747be328..c421a66b4 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -408,6 +408,15 @@ android:authorities="com.google.android.gms.auth.accounts" android:exported="true" /> + + + + + + + diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/CredentialPickerActivity.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/CredentialPickerActivity.kt new file mode 100644 index 000000000..c5f3849c0 --- /dev/null +++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/CredentialPickerActivity.kt @@ -0,0 +1,38 @@ +/* + * SPDX-FileCopyrightText: 2021, microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.ui + +import android.app.Activity +import android.os.Bundle +import android.os.Parcel +import android.os.Parcelable +import android.util.Log +import com.google.android.gms.auth.api.credentials.CredentialRequest +import com.google.android.gms.auth.api.credentials.HintRequest + +fun Parcelable.Creator.createFromBytes(bytes: ByteArray): T { + val parcel = Parcel.obtain() + parcel.unmarshall(bytes, 0, bytes.size) + parcel.setDataPosition(0) + try { + return createFromParcel(parcel) + } finally { + parcel.recycle() + } +} + +class CredentialPickerActivity : Activity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val extras = intent.extras ?: Bundle() + val callingPackage = callingActivity?.packageName?.takeIf { extras.getString("claimedCallingPackage", it) == it } + val logSessionId = extras.getString("logSessionId") + val credentialRequest = extras.getByteArray("credentialRequest")?.let { CredentialRequest.CREATOR.createFromBytes(it) } + val hintRequest = extras.getByteArray("com.google.android.gms.credentials.HintRequest")?.let { HintRequest.CREATOR.createFromBytes(it) } + Log.d("GmsCredentialPicker", "Not implemented. callingPackage=$callingPackage, logSessionId=$logSessionId, credentialsRequest=$credentialRequest, hintRequest=$hintRequest") + finish() + } +} -- GitLab From a173d268973dac2386504d96419d513ecc45b90c Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 15 Apr 2021 12:06:44 +0200 Subject: [PATCH 15/33] Announce (unsupported) feature in location manager --- .../microg/gms/location/GoogleLocationManagerService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerService.java b/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerService.java index f2761010a..1ed8ba4b5 100644 --- a/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerService.java +++ b/play-services-location-core/src/main/java/org/microg/gms/location/GoogleLocationManagerService.java @@ -19,6 +19,8 @@ package org.microg.gms.location; import android.os.RemoteException; import android.util.Log; +import com.google.android.gms.common.Feature; +import com.google.android.gms.common.internal.ConnectionInfo; import com.google.android.gms.common.internal.GetServiceRequest; import com.google.android.gms.common.internal.IGmsCallbacks; @@ -36,7 +38,11 @@ public class GoogleLocationManagerService extends BaseService { public void handleServiceRequest(IGmsCallbacks callback, GetServiceRequest request, GmsService service) throws RemoteException { impl.invokeOnceReady(() -> { try { - callback.onPostInitComplete(0, impl.asBinder(), null); + ConnectionInfo info = new ConnectionInfo(); + info.features = new Feature[] { + new Feature("name_sleep_segment_request", 1) + }; + callback.onPostInitCompleteWithConnectionInfo(0, impl.asBinder(), info); } catch (RemoteException e) { Log.w(TAG, e); } -- GitLab From 8dceaad8eaed4599590779634c3830c62d9a2784 Mon Sep 17 00:00:00 2001 From: fynngodau Date: Sat, 17 Apr 2021 13:20:30 +0200 Subject: [PATCH 16/33] Fix date format being used incorrectly (#1443) fixes #1441 --- .../org/microg/gms/nearby/core/ui/DotChartView.kt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt index 76e5590d1..e08a02a58 100644 --- a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt +++ b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt @@ -10,14 +10,12 @@ import android.annotation.TargetApi import android.content.Context import android.graphics.* import android.os.Build -import android.provider.Settings -import android.text.TextUtils +import android.text.format.DateFormat import android.util.AttributeSet import android.view.MotionEvent import android.view.View import org.microg.gms.nearby.exposurenotification.ExposureScanSummary import org.microg.gms.ui.resolveColor -import java.text.SimpleDateFormat import java.util.* import kotlin.math.max import kotlin.math.min @@ -38,12 +36,7 @@ class DotChartView : View { val now = System.currentTimeMillis() val min = now - 14 * 24 * 60 * 60 * 1000L val date = Date(min) - val format = Settings.System.getString(context.contentResolver, Settings.System.DATE_FORMAT); - val dateFormat = if (TextUtils.isEmpty(format)) { - android.text.format.DateFormat.getMediumDateFormat(context) - } else { - SimpleDateFormat(format) - } + val dateFormat = DateFormat.getMediumDateFormat(context) val lowest = dateFormat.parse(dateFormat.format(date))?.time ?: date.time for (day in 0 until 15) { date.time = now - (14 - day) * 24 * 60 * 60 * 1000L -- GitLab From 63d09df2fc0720a2474ffc3bd3a5d9bced0f8a99 Mon Sep 17 00:00:00 2001 From: Oliver Scott Date: Thu, 1 Apr 2021 11:13:43 -0400 Subject: [PATCH 17/33] Replace remaining shared preference edits with service configuration setters Change-Id: I518f54653791ce02cb0e82662802474c5e8852d5 --- .../org/microg/gms/provision/ProvisionService.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/play-services-core/src/main/kotlin/org/microg/gms/provision/ProvisionService.kt b/play-services-core/src/main/kotlin/org/microg/gms/provision/ProvisionService.kt index 79fd32c52..df37e477e 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/provision/ProvisionService.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/provision/ProvisionService.kt @@ -12,11 +12,12 @@ import android.util.Log import androidx.lifecycle.LifecycleService import androidx.lifecycle.lifecycleScope import kotlinx.coroutines.delay -import org.microg.gms.checkin.CheckinPrefs -import org.microg.gms.gcm.GcmPrefs +import org.microg.gms.checkin.getCheckinServiceInfo +import org.microg.gms.checkin.setCheckinServiceConfiguration import org.microg.gms.gcm.getGcmServiceInfo import org.microg.gms.gcm.setGcmServiceConfiguration -import org.microg.gms.snet.SafetyNetPrefs +import org.microg.gms.snet.getSafetyNetServiceInfo +import org.microg.gms.snet.setSafetyNetServiceConfiguration class ProvisionService : LifecycleService() { private fun Bundle.getBooleanOrNull(key: String): Boolean? { @@ -31,9 +32,9 @@ class ProvisionService : LifecycleService() { Log.d(TAG, "Provisioning: $s") } - intent?.extras?.getBooleanOrNull("checkin_enabled")?.let { CheckinPrefs.setEnabled(this@ProvisionService, it) } + intent?.extras?.getBooleanOrNull("checkin_enabled")?.let { setCheckinServiceConfiguration(this@ProvisionService, getCheckinServiceInfo(this@ProvisionService).configuration.copy(enabled = it)) } intent?.extras?.getBooleanOrNull("gcm_enabled")?.let { setGcmServiceConfiguration(this@ProvisionService, getGcmServiceInfo(this@ProvisionService).configuration.copy(enabled = it)) } - intent?.extras?.getBooleanOrNull("safetynet_enabled")?.let { SafetyNetPrefs.get(this@ProvisionService).isEnabled = it } + intent?.extras?.getBooleanOrNull("safetynet_enabled")?.let { setSafetyNetServiceConfiguration(this@ProvisionService, getSafetyNetServiceInfo(this@ProvisionService).configuration.copy(enabled = it)) } // What else? delay(2 * 1000) // Wait 2 seconds to give provisioning some extra time -- GitLab From 1a149c6c51d409f551f339c63ba76b2030fe2853 Mon Sep 17 00:00:00 2001 From: Dima Ryazanov Date: Mon, 11 Jan 2021 14:06:43 -0800 Subject: [PATCH 18/33] Add Chat to known Google packages --- .../src/main/java/org/microg/gms/common/PackageUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java b/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java index 965edca2e..553b1f25f 100644 --- a/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java +++ b/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java @@ -67,6 +67,7 @@ public class PackageUtils { KNOWN_GOOGLE_PACKAGES.put("com.google.android.apps.subscriptions.red", "de8304ace744ae4c4e05887a27a790815e610ff0"); KNOWN_GOOGLE_PACKAGES.put("com.google.android.apps.meetings", "47a6936b733dbdb45d71997fbe1d610eca36b8bf"); KNOWN_GOOGLE_PACKAGES.put("com.google.android.apps.nbu.paisa.user", "80df78bb700f9172bc671779b017ddefefcbf552"); + KNOWN_GOOGLE_PACKAGES.put("com.google.android.apps.dynamite", "519c5a17a60596e6fe5933b9cb4285e7b0e5eb7b"); } public static boolean isGooglePackage(Context context, String packageName) { -- GitLab From e9f028c813562fef5ea926acc4c0209f0632fe14 Mon Sep 17 00:00:00 2001 From: Dylanger Daly Date: Sun, 18 Apr 2021 00:20:26 +1000 Subject: [PATCH 19/33] Add Android Auto to known Google packages (#1396) --- .../src/main/java/org/microg/gms/common/PackageUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java b/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java index 553b1f25f..368e19058 100644 --- a/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java +++ b/play-services-base-core/src/main/java/org/microg/gms/common/PackageUtils.java @@ -68,6 +68,7 @@ public class PackageUtils { KNOWN_GOOGLE_PACKAGES.put("com.google.android.apps.meetings", "47a6936b733dbdb45d71997fbe1d610eca36b8bf"); KNOWN_GOOGLE_PACKAGES.put("com.google.android.apps.nbu.paisa.user", "80df78bb700f9172bc671779b017ddefefcbf552"); KNOWN_GOOGLE_PACKAGES.put("com.google.android.apps.dynamite", "519c5a17a60596e6fe5933b9cb4285e7b0e5eb7b"); + KNOWN_GOOGLE_PACKAGES.put("com.google.android.projection.gearhead", "9ca91f9e704d630ef67a23f52bf1577a92b9ca5d"); } public static boolean isGooglePackage(Context context, String packageName) { -- GitLab From ad12bd5de4970a6607a18e37707fab9f444593a7 Mon Sep 17 00:00:00 2001 From: Francesco Saltori Date: Mon, 19 Apr 2021 12:42:53 +0200 Subject: [PATCH 20/33] Handle GMS intent for launching account settings (#1452) --- play-services-core/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index c421a66b4..c3df7f9bc 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -538,6 +538,7 @@ + -- GitLab From aee45c22befdc268eeee65987a5d8e091ae7427d Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 28 Apr 2021 20:08:19 +0200 Subject: [PATCH 21/33] EN: Add implementation for getStatus() --- .../ExposureNotificationServiceImpl.kt | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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 566a0f9ae..ade3a2326 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 @@ -9,8 +9,10 @@ import android.app.Activity import android.app.PendingIntent import android.bluetooth.BluetoothAdapter import android.content.* +import android.location.LocationManager import android.os.* import android.util.Log +import androidx.core.location.LocationManagerCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.LifecycleOwner @@ -622,11 +624,33 @@ class ExposureNotificationServiceImpl(private val context: Context, private val override fun getStatus(params: GetStatusParams) { Log.w(TAG, "Not yet implemented: getStatus") lifecycleScope.launchSafely { - ExposureDatabase.with(context) { database -> + val isAuthorized = ExposureDatabase.with(context) { database -> database.noteAppAction(packageName, "getStatus") + database.isAppAuthorized(packageName) + } + val flags = hashSetOf() + val adapter = BluetoothAdapter.getDefaultAdapter() + if (adapter == null || !adapter.isEnabled) { + flags.add(ExposureNotificationStatus.BLUETOOTH_DISABLED) + flags.add(ExposureNotificationStatus.BLUETOOTH_SUPPORT_UNKNOWN) + } else if (Build.VERSION.SDK_INT < 21) { + flags.add(ExposureNotificationStatus.EN_NOT_SUPPORT) + } else if (adapter.bluetoothLeScanner == null){ + flags.add(ExposureNotificationStatus.HW_NOT_SUPPORT) + } + if (!LocationManagerCompat.isLocationEnabled(context.getSystemService(Context.LOCATION_SERVICE) as LocationManager)) { + flags.add(ExposureNotificationStatus.LOCATION_DISABLED) + } + if (!isAuthorized) { + flags.add(ExposureNotificationStatus.NO_CONSENT) + } + if (isAuthorized && ExposurePreferences(context).enabled) { + flags.add(ExposureNotificationStatus.ACTIVATED) + } else { + flags.add(ExposureNotificationStatus.INACTIVATED) } try { - params.callback.onResult(Status.SUCCESS, ExposureNotificationStatus.setToFlags(setOf(ExposureNotificationStatus.UNKNOWN))) + params.callback.onResult(Status.SUCCESS, ExposureNotificationStatus.setToFlags(flags)) } catch (e: Exception) { Log.w(TAG, "Callback failed", e) } -- GitLab From 9eb0adda9dbe79ad88729c4444086a56244fd376 Mon Sep 17 00:00:00 2001 From: fynngodau Date: Wed, 5 May 2021 23:20:23 +0200 Subject: [PATCH 22/33] Omit RPIs in log (#1464) --- .../gms/nearby/exposurenotification/AdvertiserService.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt index 4961c312c..396064aed 100644 --- a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt +++ b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt @@ -138,8 +138,7 @@ class AdvertiserService : LifecycleService() { database.generateCurrentPayload(aemBytes) } val data = AdvertiseData.Builder().addServiceUuid(SERVICE_UUID).addServiceData(SERVICE_UUID, payload).build() - val (uuid, _) = ByteBuffer.wrap(payload).let { UUID(it.long, it.long) to it.int } - Log.i(TAG, "Starting advertiser for RPI $uuid") + Log.i(TAG, "Starting advertiser") if (Build.VERSION.SDK_INT >= 26) { setCallback = SetCallback() val params = AdvertisingSetParameters.Builder() @@ -201,8 +200,7 @@ class AdvertiserService : LifecycleService() { @Synchronized private fun stopOrRestartAdvertising() { if (!advertising) return - val (uuid, _) = ByteBuffer.wrap(sendingBytes).let { UUID(it.long, it.long) to it.int } - Log.i(TAG, "Stopping advertiser for RPI $uuid") + Log.i(TAG, "Stopping advertiser") advertising = false if (Build.VERSION.SDK_INT >= 26) { wantStartAdvertising = true -- GitLab From c9d767dd8030719ff0c548435b2989373bcf6a2e Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Tue, 4 May 2021 19:23:46 +0200 Subject: [PATCH 23/33] Allow drawing RPIs fragment under system navbars --- .../core/ui/ExposureNotificationsRpisFragment.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsRpisFragment.kt b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsRpisFragment.kt index 339bc88af..f6fc8d83e 100644 --- a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsRpisFragment.kt +++ b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/ExposureNotificationsRpisFragment.kt @@ -7,11 +7,14 @@ package org.microg.gms.nearby.core.ui import android.annotation.TargetApi import android.os.Bundle +import android.view.LayoutInflater +import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import androidx.lifecycle.lifecycleScope import androidx.preference.Preference import androidx.preference.PreferenceCategory import androidx.preference.PreferenceFragmentCompat +import androidx.recyclerview.widget.RecyclerView import org.microg.gms.nearby.exposurenotification.ExposureDatabase @TargetApi(21) @@ -21,6 +24,18 @@ class ExposureNotificationsRpisFragment : PreferenceFragmentCompat() { private lateinit var deleteAll: Preference private lateinit var exportDb: Preference + override fun onCreateRecyclerView( + inflater: LayoutInflater?, + parent: ViewGroup?, + savedInstanceState: Bundle? + ): RecyclerView { + return super.onCreateRecyclerView(inflater, parent, savedInstanceState).apply { + // Allow drawing under system navbar / status bar + fitsSystemWindows = true + clipToPadding = false + } + } + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.preferences_exposure_notifications_rpis) } -- GitLab From f5cd584a0a4c6556664dc6eab9113b423942a216 Mon Sep 17 00:00:00 2001 From: Nico Date: Wed, 5 May 2021 23:21:43 +0200 Subject: [PATCH 24/33] Correct grammar (#1462) --- play-services-core/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play-services-core/src/main/res/values/strings.xml b/play-services-core/src/main/res/values/strings.xml index 12ffbc25f..2f2e57526 100644 --- a/play-services-core/src/main/res/values/strings.xml +++ b/play-services-core/src/main/res/values/strings.xml @@ -30,7 +30,7 @@ If this was intentional, use the Sign in button to connect to Google’s sign-in page, if not, press Cancel to go back to the application that caused this dialog to show up." Sign in - "Your device is establishing an connection to Google’s servers to sign you in. + "Your device is establishing a connection to Google’s servers to sign you in. This can take a few seconds." "You don’t have a network connection. -- GitLab From 7f131c0cfa30f9b97b65b33efb62985e155e2fc3 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 28 Apr 2021 20:36:51 +0200 Subject: [PATCH 25/33] ENUI: Make date to dot position based on DateFormat Should fix #1444 --- .../org/microg/gms/nearby/core/ui/DotChartView.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt index e08a02a58..0ceb71e05 100644 --- a/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt +++ b/play-services-nearby-core-ui/src/main/kotlin/org/microg/gms/nearby/core/ui/DotChartView.kt @@ -16,6 +16,7 @@ import android.view.MotionEvent import android.view.View import org.microg.gms.nearby.exposurenotification.ExposureScanSummary import org.microg.gms.ui.resolveColor +import java.text.SimpleDateFormat import java.util.* import kotlin.math.max import kotlin.math.min @@ -37,18 +38,24 @@ class DotChartView : View { val min = now - 14 * 24 * 60 * 60 * 1000L val date = Date(min) val dateFormat = DateFormat.getMediumDateFormat(context) + val hourFormat = SimpleDateFormat("H") val lowest = dateFormat.parse(dateFormat.format(date))?.time ?: date.time for (day in 0 until 15) { date.time = now - (14 - day) * 24 * 60 * 60 * 1000L displayData[day] = dateFormat.format(date) to hashMapOf() } + fun dayByDate(date: Date) : Int? { + val dateString = dateFormat.format(date) + return displayData.entries.firstOrNull { it.value.first == dateString }?.key + } if (value != null) { for (summary in value) { val off = summary.time - lowest if (off < 0) continue val totalHours = (off / 1000 / 60 / 60).toInt() - val day = totalHours / 24 - val hour = totalHours % 24 + date.time = summary.time + val day = dayByDate(date) ?: (totalHours / 24) + val hour = hourFormat.format(date).toIntOrNull() ?: (totalHours % 24) displayData[day]?.second?.set(hour, (displayData[day]?.second?.get(hour) ?: 0) + summary.rpis) } } -- GitLab From 1a809e0e478718ef7422b231a9d6b35652b79824 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 5 May 2021 23:29:02 +0200 Subject: [PATCH 26/33] SafetyNet updates - Add more API details - preliminary support for SafetyNet reCAPTCHA - prepare for improved DroidGuard handling --- build.gradle | 1 + .../gms/safetynet/HarmfulAppsInfo.aidl | 3 + .../gms/safetynet/RecaptchaResultData.aidl | 3 + .../gms/safetynet/RemoveHarmfulAppData.aidl | 3 + .../internal/ISafetyNetCallbacks.aidl | 8 +- .../safetynet/internal/ISafetyNetService.aidl | 3 +- .../gms/safetynet/HarmfulAppsData.java | 52 +++-- .../gms/safetynet/HarmfulAppsInfo.java | 32 +++ .../gms/safetynet/RecaptchaResultData.java | 26 +++ .../gms/safetynet/RemoveHarmfulAppData.java | 28 +++ .../gms/safetynet/SafeBrowsingData.java | 24 ++- .../gms/safetynet/SafetyNetStatusCodes.java | 37 ++++ .../gms/safetynet/VerifyAppsConstants.java | 52 +++++ .../src/main/res/values/themes.xml | 5 + .../org/microg/gms/common/GmsService.java | 40 ++++ play-services-core/build.gradle | 3 + .../src/main/AndroidManifest.xml | 22 +- .../gms/{snet => safetynet}/Attestation.java | 67 +++--- .../{snet => safetynet}/SafetyNetPrefs.java | 18 +- .../gms/snet/SafetyNetClientService.java | 37 ---- .../gms/snet/SafetyNetClientServiceImpl.java | 137 ------------ .../gms/ui/SafetyNetAdvancedFragment.java | 6 +- .../gms/droidguard/DroidGuardPreferences.kt | 70 ++++++ .../gms/droidguard/DroidGuardResultCreator.kt | 70 ++++++ .../org/microg/gms/droidguard/ServiceInfo.kt | 93 ++++++++ .../microg/gms/recaptcha/ReCaptchaActivity.kt | 204 ++++++++++++++++++ .../gms/safetynet/SafetyNetClientService.kt | 156 ++++++++++++++ .../gms/{snet => safetynet}/ServiceInfo.kt | 4 +- .../org/microg/gms/ui/SafetyNetFragment.kt | 6 +- .../src/main/res/drawable/ic_recaptcha.xml | 64 ++++++ .../src/main/res/layout/ask_gcm.xml | 18 +- .../src/main/res/layout/recaptcha_window.xml | 68 ++++++ 32 files changed, 1093 insertions(+), 267 deletions(-) create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/safetynet/HarmfulAppsInfo.aidl create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/safetynet/RecaptchaResultData.aidl create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/safetynet/RemoveHarmfulAppData.aidl create mode 100644 play-services-api/src/main/java/com/google/android/gms/safetynet/HarmfulAppsInfo.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/safetynet/RecaptchaResultData.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/safetynet/RemoveHarmfulAppData.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/safetynet/SafetyNetStatusCodes.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/safetynet/VerifyAppsConstants.java rename play-services-core/src/main/java/org/microg/gms/{snet => safetynet}/Attestation.java (75%) rename play-services-core/src/main/java/org/microg/gms/{snet => safetynet}/SafetyNetPrefs.java (85%) delete mode 100644 play-services-core/src/main/java/org/microg/gms/snet/SafetyNetClientService.java delete mode 100644 play-services-core/src/main/java/org/microg/gms/snet/SafetyNetClientServiceImpl.java create mode 100644 play-services-core/src/main/kotlin/org/microg/gms/droidguard/DroidGuardPreferences.kt create mode 100644 play-services-core/src/main/kotlin/org/microg/gms/droidguard/DroidGuardResultCreator.kt create mode 100644 play-services-core/src/main/kotlin/org/microg/gms/droidguard/ServiceInfo.kt create mode 100644 play-services-core/src/main/kotlin/org/microg/gms/recaptcha/ReCaptchaActivity.kt create mode 100644 play-services-core/src/main/kotlin/org/microg/gms/safetynet/SafetyNetClientService.kt rename play-services-core/src/main/kotlin/org/microg/gms/{snet => safetynet}/ServiceInfo.kt (97%) create mode 100644 play-services-core/src/main/res/drawable/ic_recaptcha.xml create mode 100644 play-services-core/src/main/res/layout/recaptcha_window.xml diff --git a/build.gradle b/build.gradle index c42bb3b4d..86293c26c 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,7 @@ buildscript { ext.navigationVersion = '2.3.1' ext.preferenceVersion = '1.1.1' ext.recyclerviewVersion = '1.1.0' + ext.webkitVersion = '1.4.0' ext.supportLibraryVersion = '28.0.0' ext.slf4jVersion = '1.7.25' diff --git a/play-services-api/src/main/aidl/com/google/android/gms/safetynet/HarmfulAppsInfo.aidl b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/HarmfulAppsInfo.aidl new file mode 100644 index 000000000..becadfaf9 --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/HarmfulAppsInfo.aidl @@ -0,0 +1,3 @@ +package com.google.android.gms.safetynet; + +parcelable HarmfulAppsInfo; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/safetynet/RecaptchaResultData.aidl b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/RecaptchaResultData.aidl new file mode 100644 index 000000000..ec4cbb4f1 --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/RecaptchaResultData.aidl @@ -0,0 +1,3 @@ +package com.google.android.gms.safetynet; + +parcelable RecaptchaResultData; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/safetynet/RemoveHarmfulAppData.aidl b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/RemoveHarmfulAppData.aidl new file mode 100644 index 000000000..af859cde0 --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/RemoveHarmfulAppData.aidl @@ -0,0 +1,3 @@ +package com.google.android.gms.safetynet; + +parcelable RemoveHarmfulAppData; diff --git a/play-services-api/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetCallbacks.aidl b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetCallbacks.aidl index fe57be6d9..13e1ee40d 100644 --- a/play-services-api/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetCallbacks.aidl +++ b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetCallbacks.aidl @@ -3,6 +3,9 @@ package com.google.android.gms.safetynet.internal; import com.google.android.gms.common.api.Status; import com.google.android.gms.safetynet.AttestationData; import com.google.android.gms.safetynet.HarmfulAppsData; +import com.google.android.gms.safetynet.HarmfulAppsInfo; +import com.google.android.gms.safetynet.RecaptchaResultData; +import com.google.android.gms.safetynet.RemoveHarmfulAppData; import com.google.android.gms.safetynet.SafeBrowsingData; interface ISafetyNetCallbacks { @@ -11,4 +14,7 @@ interface ISafetyNetCallbacks { void onSafeBrowsingData(in Status status, in SafeBrowsingData safeBrowsingData) = 2; void onBoolean(in Status status, boolean b) = 3; void onHarmfulAppsData(in Status status, in List harmfulAppsData) = 4; -} \ No newline at end of file + void onRecaptchaResult(in Status status, in RecaptchaResultData recaptchaResultData) = 5; + void onHarmfulAppsInfo(in Status status, in HarmfulAppsInfo harmfulAppsInfo) = 7; + void onRemoveHarmfulAppData(in Status status, in RemoveHarmfulAppData removeHarmfulAppData) = 14; +} diff --git a/play-services-api/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetService.aidl b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetService.aidl index 7dfc749b8..5cf8b2a1b 100644 --- a/play-services-api/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetService.aidl +++ b/play-services-api/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetService.aidl @@ -9,4 +9,5 @@ interface ISafetyNetService { void lookupUri(ISafetyNetCallbacks callbacks, String s1, in int[] threatTypes, int i, String s2) = 2; void init(ISafetyNetCallbacks callbacks) = 3; void getHarmfulAppsList(ISafetyNetCallbacks callbacks) = 4; -} \ No newline at end of file + void verifyWithRecaptcha(ISafetyNetCallbacks callbacks, String siteKey) = 5; +} diff --git a/play-services-api/src/main/java/com/google/android/gms/safetynet/HarmfulAppsData.java b/play-services-api/src/main/java/com/google/android/gms/safetynet/HarmfulAppsData.java index 7ac285fee..e043522b4 100644 --- a/play-services-api/src/main/java/com/google/android/gms/safetynet/HarmfulAppsData.java +++ b/play-services-api/src/main/java/com/google/android/gms/safetynet/HarmfulAppsData.java @@ -1,23 +1,49 @@ /* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2021, 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.safetynet; +import org.microg.gms.common.PublicApi; import org.microg.safeparcel.AutoSafeParcelable; +/** + * APK information pertaining to one potentially harmful app. + */ +@PublicApi public class HarmfulAppsData extends AutoSafeParcelable { + /** + * The package name of the potentially harmful app. + */ + @Field(2) + public final String apkPackageName; + /** + * The SHA-256 of the potentially harmful app APK file. + */ + @Field(3) + public final byte[] apkSha256; + /** + * The potentially harmful app category defined in {@link VerifyAppsConstants}. + */ + @Field(4) + public final int apkCategory; + + private HarmfulAppsData() { + apkPackageName = null; + apkSha256 = null; + apkCategory = 0; + } + + @PublicApi(exclude = true) + public HarmfulAppsData(String apkPackageName, byte[] apkSha256, int apkCategory) { + this.apkPackageName = apkPackageName; + this.apkSha256 = apkSha256; + this.apkCategory = apkCategory; + } + public static final Creator CREATOR = new AutoCreator(HarmfulAppsData.class); } diff --git a/play-services-api/src/main/java/com/google/android/gms/safetynet/HarmfulAppsInfo.java b/play-services-api/src/main/java/com/google/android/gms/safetynet/HarmfulAppsInfo.java new file mode 100644 index 000000000..6ae6bf653 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/safetynet/HarmfulAppsInfo.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2013-2017 microG Project Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.gms.safetynet; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class HarmfulAppsInfo extends AutoSafeParcelable { + @Field(2) + public long field2; + @Field(3) + public HarmfulAppsData[] data; + @Field(4) + public int field4; + @Field(5) + public boolean field5; + + public static final Creator CREATOR = new AutoCreator(HarmfulAppsInfo.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/safetynet/RecaptchaResultData.java b/play-services-api/src/main/java/com/google/android/gms/safetynet/RecaptchaResultData.java new file mode 100644 index 000000000..748f11293 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/safetynet/RecaptchaResultData.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2013-2017 microG Project Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.gms.safetynet; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class RecaptchaResultData extends AutoSafeParcelable { + @Field(2) + public String token; + + public static final Creator CREATOR = new AutoCreator(RecaptchaResultData.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/safetynet/RemoveHarmfulAppData.java b/play-services-api/src/main/java/com/google/android/gms/safetynet/RemoveHarmfulAppData.java new file mode 100644 index 000000000..32901e077 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/safetynet/RemoveHarmfulAppData.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2013-2017 microG Project Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.gms.safetynet; + +import org.microg.safeparcel.AutoSafeParcelable; + +public class RemoveHarmfulAppData extends AutoSafeParcelable { + @Field(2) + public int field2; + @Field(3) + public boolean field3; + + public static final Creator CREATOR = new AutoCreator(RemoveHarmfulAppData.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/safetynet/SafeBrowsingData.java b/play-services-api/src/main/java/com/google/android/gms/safetynet/SafeBrowsingData.java index 80fc8c5ce..f0017e6af 100644 --- a/play-services-api/src/main/java/com/google/android/gms/safetynet/SafeBrowsingData.java +++ b/play-services-api/src/main/java/com/google/android/gms/safetynet/SafeBrowsingData.java @@ -16,18 +16,30 @@ package com.google.android.gms.safetynet; +import android.os.ParcelFileDescriptor; + import com.google.android.gms.common.data.DataHolder; import org.microg.safeparcel.AutoSafeParcelable; import org.microg.safeparcel.SafeParceled; +import java.io.File; + public class SafeBrowsingData extends AutoSafeParcelable { - @SafeParceled(1) - private int versionCode = 1; - @SafeParceled(2) - private String status; - @SafeParceled(3) - private DataHolder data; + @Field(1) + public int versionCode = 1; + @Field(2) + public String status; + @Field(3) + public DataHolder data; + @Field(4) + public ParcelFileDescriptor fileDescriptor; + public File file; + public byte[] fileContents; + @Field(5) + public long field5; + @Field(6) + public byte[] field6; public static final Creator CREATOR = new AutoCreator(SafeBrowsingData.class); } diff --git a/play-services-api/src/main/java/com/google/android/gms/safetynet/SafetyNetStatusCodes.java b/play-services-api/src/main/java/com/google/android/gms/safetynet/SafetyNetStatusCodes.java new file mode 100644 index 000000000..203cb0c4e --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/safetynet/SafetyNetStatusCodes.java @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2021, 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.safetynet; + +import com.google.android.gms.common.api.CommonStatusCodes; + +/** + * Status codes for the SafetyNet API. + */ +public class SafetyNetStatusCodes extends CommonStatusCodes { + public static final int SAFE_BROWSING_UNSUPPORTED_THREAT_TYPES = 12000; + public static final int SAFE_BROWSING_MISSING_API_KEYINT = 12001; + public static final int SAFE_BROWSING_API_NOT_AVAILABLE = 12002; + public static final int VERIFY_APPS_NOT_AVAILABLE = 12003; + public static final int VERIFY_APPS_INTERNAL_ERROR = 12004; + public static final int VERIFY_APPS_NOT_ENABLED = 12005; + public static final int UNSUPPORTED_SDK_VERSION = 12006; + /** + * Cannot start the reCAPTCHA service because site key parameter is not valid. + */ + public static final int RECAPTCHA_INVALID_SITEKEY = 12007; + /** + * Cannot start the reCAPTCHA service because type of site key is not valid. + */ + public static final int RECAPTCHA_INVALID_KEYTYPE = 12008; + public static final int SAFE_BROWSING_API_NOT_INITIALIZED = 12009; + /** + * Cannot start the reCAPTCHA service because calling package name is not matched with site key. + */ + public static final int RECAPTCHA_INVALID_PACKAGE_NAME = 12013; +} diff --git a/play-services-api/src/main/java/com/google/android/gms/safetynet/VerifyAppsConstants.java b/play-services-api/src/main/java/com/google/android/gms/safetynet/VerifyAppsConstants.java new file mode 100644 index 000000000..bec6b746c --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/safetynet/VerifyAppsConstants.java @@ -0,0 +1,52 @@ +/* + * SPDX-FileCopyrightText: 2021, 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.safetynet; + +import org.microg.gms.common.PublicApi; + +/** + * Constants pertaining to the Verify Apps SafetyNet API. + */ +@PublicApi +public class VerifyAppsConstants { + /** + * An action that is broadcasted when harmful apps are discovered. + */ + public static final String ACTION_HARMFUL_APPS_FOUND = "com.google.android.gms.safetynet.action.HARMFUL_APPS_FOUND"; + /** + * An action that is broadcasted when a harmful app is blocked from installation. + */ + public static final String ACTION_HARMFUL_APP_BLOCKED = "com.google.android.gms.safetynet.action.HARMFUL_APP_BLOCKED"; + /** + * An action that is broadcasted when a harmful app is installed. + */ + public static final String ACTION_HARMFUL_APP_INSTALLED = "com.google.android.gms.safetynet.action.HARMFUL_APP_INSTALLED"; + + public static final int HARMFUL_CATEGORY_RANSOMWARE = 1; + public static final int HARMFUL_CATEGORY_PHISHING = 2; + public static final int HARMFUL_CATEGORY_TROJAN = 3; + public static final int HARMFUL_CATEGORY_UNCOMMON = 4; + public static final int HARMFUL_CATEGORY_FRAUDWARE = 5; + public static final int HARMFUL_CATEGORY_TOLL_FRAUD = 6; + public static final int HARMFUL_CATEGORY_WAP_FRAUD = 7; + public static final int HARMFUL_CATEGORY_CALL_FRAUD = 8; + public static final int HARMFUL_CATEGORY_BACKDOOR = 9; + public static final int HARMFUL_CATEGORY_SPYWARE = 10; + public static final int HARMFUL_CATEGORY_GENERIC_MALWARE = 11; + public static final int HARMFUL_CATEGORY_HARMFUL_SITE = 12; + public static final int HARMFUL_CATEGORY_WINDOWS_MALWARE = 13; + public static final int HARMFUL_CATEGORY_HOSTILE_DOWNLOADER = 14; + public static final int HARMFUL_CATEGORY_NON_ANDROID_THREAT = 15; + public static final int HARMFUL_CATEGORY_ROOTING = 16; + public static final int HARMFUL_CATEGORY_PRIVILEGE_ESCALATION = 17; + public static final int HARMFUL_CATEGORY_TRACKING = 18; + public static final int HARMFUL_CATEGORY_SPAM = 19; + public static final int HARMFUL_CATEGORY_DENIAL_OF_SERVICE = 20; + public static final int HARMFUL_CATEGORY_DATA_COLLECTION = 21; +} diff --git a/play-services-base-core-ui/src/main/res/values/themes.xml b/play-services-base-core-ui/src/main/res/values/themes.xml index a32388e21..2130e2780 100644 --- a/play-services-base-core-ui/src/main/res/values/themes.xml +++ b/play-services-base-core-ui/src/main/res/values/themes.xml @@ -6,6 +6,11 @@ + +