From ad12bd5de4970a6607a18e37707fab9f444593a7 Mon Sep 17 00:00:00 2001 From: Francesco Saltori Date: Mon, 19 Apr 2021 12:42:53 +0200 Subject: [PATCH 01/15] 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 c421a66b..c3df7f9b 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -538,6 +538,7 @@ + From aee45c22befdc268eeee65987a5d8e091ae7427d Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 28 Apr 2021 20:08:19 +0200 Subject: [PATCH 02/15] 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 566a0f9a..ade3a232 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) } From 9eb0adda9dbe79ad88729c4444086a56244fd376 Mon Sep 17 00:00:00 2001 From: fynngodau Date: Wed, 5 May 2021 23:20:23 +0200 Subject: [PATCH 03/15] 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 4961c312..396064ae 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 From c9d767dd8030719ff0c548435b2989373bcf6a2e Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Tue, 4 May 2021 19:23:46 +0200 Subject: [PATCH 04/15] 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 339bc88a..f6fc8d83 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) } From f5cd584a0a4c6556664dc6eab9113b423942a216 Mon Sep 17 00:00:00 2001 From: Nico Date: Wed, 5 May 2021 23:21:43 +0200 Subject: [PATCH 05/15] 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 12ffbc25..2f2e5752 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. From 7f131c0cfa30f9b97b65b33efb62985e155e2fc3 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 28 Apr 2021 20:36:51 +0200 Subject: [PATCH 06/15] 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 e08a02a5..0ceb71e0 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) } } From 1a809e0e478718ef7422b231a9d6b35652b79824 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Wed, 5 May 2021 23:29:02 +0200 Subject: [PATCH 07/15] 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 c42bb3b4..86293c26 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 00000000..becadfaf --- /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 00000000..ec4cbb4f --- /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 00000000..af859cde --- /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 fe57be6d..13e1ee40 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 7dfc749b..5cf8b2a1 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 7ac285fe..e043522b 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 00000000..6ae6bf65 --- /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 00000000..748f1129 --- /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 00000000..32901e07 --- /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 80fc8c5c..f0017e6a 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 00000000..203cb0c4 --- /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 00000000..bec6b746 --- /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 a32388e2..2130e278 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 @@ + +