From 9be1538fd28c554cbdbd7733b99bd7e32dc3d8e3 Mon Sep 17 00:00:00 2001 From: Tommy Webb Date: Mon, 31 Jul 2023 15:40:12 -0400 Subject: [PATCH 01/10] Provisioning: Location providers New provisioning extras to control Location features: * Internet lookups (Mozilla Location Services): wifi_mls, cell_mls * Local location learning: wifi_learning, cell_learning * Query location from supported hotspots: wifi_moving * Geocoder (Nominatim): nominatim_enabled Change-Id: I334c4f92437257dac261cbc9644641df9a9eaf55 --- play-services-core/build.gradle | 1 + .../org/microg/gms/provision/ProvisionService.kt | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/play-services-core/build.gradle b/play-services-core/build.gradle index b339b2dadd..88615a87a4 100644 --- a/play-services-core/build.gradle +++ b/play-services-core/build.gradle @@ -33,6 +33,7 @@ dependencies { implementation project(':play-services-fido-core') implementation project(':play-services-gmscompliance-core') implementation project(':play-services-location-core') + implementation project(':play-services-location-core-base') implementation project(':play-services-location-core-provider') withNearbyImplementation project(':play-services-nearby-core') implementation project(':play-services-oss-licenses-core') 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 b7c7da7042..3720e312ac 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 @@ -17,6 +17,7 @@ import org.microg.gms.checkin.setCheckinServiceConfiguration import org.microg.gms.droidguard.core.DroidGuardPreferences import org.microg.gms.gcm.getGcmServiceInfo import org.microg.gms.gcm.setGcmServiceConfiguration +import org.microg.gms.location.LocationSettings import org.microg.gms.safetynet.SafetyNetPreferences class ProvisionService : LifecycleService() { @@ -38,6 +39,16 @@ class ProvisionService : LifecycleService() { SafetyNetPreferences.setEnabled(this@ProvisionService, it) DroidGuardPreferences.setEnabled(this@ProvisionService, it) } + LocationSettings(this@ProvisionService).apply { + intent?.extras?.getBooleanOrNull("wifi_mls")?.let { wifiMls = it } + intent?.extras?.getBooleanOrNull("cell_mls")?.let { cellMls = it } + intent?.extras?.getBooleanOrNull("wifi_learning")?.let { wifiLearning = it } + intent?.extras?.getBooleanOrNull("cell_learning")?.let { cellLearning = it } + intent?.extras?.getBooleanOrNull("wifi_moving")?.let { wifiMoving = it } + intent?.extras?.getBooleanOrNull("nominatim_enabled")?.let { + geocoderNominatim = it + } + } // What else? delay(2 * 1000) // Wait 2 seconds to give provisioning some extra time From 1e96dd137eae86bbf3be3ca72a6345fa837ad8ff Mon Sep 17 00:00:00 2001 From: t-m-w Date: Tue, 11 Jul 2023 14:48:44 -0400 Subject: [PATCH 02/10] Set max auto heartbeat interval to 15min The previous maximum of 30 minutes is too high for a worst case, potentially resulting in massive notification delays on any network but especially on certain less-reliable networks. Change-Id: Iee64b4cfdbbefc918e70b1a9782bd1208ba9a689 --- .../src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play-services-core/src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt b/play-services-core/src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt index ae866b8bd0..b9aaeacff8 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/gcm/GcmPrefs.kt @@ -39,7 +39,7 @@ data class GcmPrefs( const val PREF_NETWORK_OTHER = Gcm.NETWORK_OTHER private const val MIN_INTERVAL = 5 * 60 * 1000 // 5 minutes - private const val MAX_INTERVAL = 30 * 60 * 1000 // 30 minutes + private const val MAX_INTERVAL = 15 * 60 * 1000 // 15 minutes @JvmStatic fun get(context: Context): GcmPrefs { From df48ad19ca41fc18321890620d86dc4337aa4222 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 21 Jul 2023 18:57:27 +0200 Subject: [PATCH 03/10] SafetyNet: Fix Verify Apps dummy --- .../gms/safetynet/SafetyNetClientService.kt | 21 ++++++++++++------- .../internal/ISafetyNetCallbacks.aidl | 2 +- .../gms/safetynet/HarmfulAppsInfo.java | 8 +++---- .../gms/safetynet/SafeBrowsingData.java | 7 +++---- .../ISafetyNetCallbacksDefaultStub.java | 2 +- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/play-services-safetynet/core/src/main/kotlin/org/microg/gms/safetynet/SafetyNetClientService.kt b/play-services-safetynet/core/src/main/kotlin/org/microg/gms/safetynet/SafetyNetClientService.kt index 1a7d63726a..160afa276a 100644 --- a/play-services-safetynet/core/src/main/kotlin/org/microg/gms/safetynet/SafetyNetClientService.kt +++ b/play-services-safetynet/core/src/main/kotlin/org/microg/gms/safetynet/SafetyNetClientService.kt @@ -20,6 +20,7 @@ import com.google.android.gms.common.api.Status import com.google.android.gms.common.internal.GetServiceRequest import com.google.android.gms.common.internal.IGmsCallbacks import com.google.android.gms.safetynet.AttestationData +import com.google.android.gms.safetynet.HarmfulAppsInfo import com.google.android.gms.safetynet.RecaptchaResultData import com.google.android.gms.safetynet.SafeBrowsingData import com.google.android.gms.safetynet.SafetyNetStatusCodes @@ -35,6 +36,7 @@ import org.microg.gms.droidguard.core.DroidGuardResultCreator import org.microg.gms.settings.SettingsContract import org.microg.gms.settings.SettingsContract.CheckIn.getContentUri import org.microg.gms.settings.SettingsContract.getSettings +import org.microg.gms.utils.warnOnTransactionIssues import java.io.IOException import java.net.URLEncoder import java.util.* @@ -142,7 +144,7 @@ class SafetyNetClientServiceImpl( // TODO Log.d(TAG, "dummy Method: getSharedUuid") - callbacks.onString("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa") + callbacks.onSharedUuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa") } override fun lookupUri(callbacks: ISafetyNetCallbacks, apiKey: String, threatTypes: IntArray, i: Int, s2: String) { @@ -156,8 +158,10 @@ class SafetyNetClientServiceImpl( } override fun listHarmfulApps(callbacks: ISafetyNetCallbacks) { - Log.d(TAG, "dummy Method: unknown4") - callbacks.onHarmfulAppsData(Status.SUCCESS, ArrayList()) + Log.d(TAG, "dummy Method: listHarmfulApps") + callbacks.onHarmfulAppsInfo(Status.SUCCESS, HarmfulAppsInfo().apply { + lastScanTime = ((System.currentTimeMillis() - VERIFY_APPS_LAST_SCAN_DELAY) / VERIFY_APPS_LAST_SCAN_TIME_ROUNDING) * VERIFY_APPS_LAST_SCAN_TIME_ROUNDING + VERIFY_APPS_LAST_SCAN_OFFSET + }) } override fun verifyWithRecaptcha(callbacks: ISafetyNetCallbacks, siteKey: String?) { @@ -262,9 +266,12 @@ class SafetyNetClientServiceImpl( callbacks.onVerifyAppsUserResult(Status.SUCCESS, true) } - 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") - return false + override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) } + + companion object { + // We simulate one scan every day, which will happen at 03:12:02.121 and will be available 32 seconds later + const val VERIFY_APPS_LAST_SCAN_DELAY = 32 * 1000L + const val VERIFY_APPS_LAST_SCAN_OFFSET = ((3 * 60 + 12) * 60 + 2) * 1000L + 121 + const val VERIFY_APPS_LAST_SCAN_TIME_ROUNDING = 24 * 60 * 60 * 1000L } } diff --git a/play-services-safetynet/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetCallbacks.aidl b/play-services-safetynet/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetCallbacks.aidl index 1ca490c0fa..db5b0f300c 100644 --- a/play-services-safetynet/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetCallbacks.aidl +++ b/play-services-safetynet/src/main/aidl/com/google/android/gms/safetynet/internal/ISafetyNetCallbacks.aidl @@ -10,7 +10,7 @@ import com.google.android.gms.safetynet.SafeBrowsingData; interface ISafetyNetCallbacks { oneway void onAttestationResult(in Status status, in AttestationData attestationData) = 0; - oneway void onString(String s) = 1; + oneway void onSharedUuid(String s) = 1; oneway void onSafeBrowsingData(in Status status, in SafeBrowsingData safeBrowsingData) = 2; oneway void onVerifyAppsUserResult(in Status status, boolean enabled) = 3; oneway void onHarmfulAppsData(in Status status, in List harmfulAppsData) = 4; diff --git a/play-services-safetynet/src/main/java/com/google/android/gms/safetynet/HarmfulAppsInfo.java b/play-services-safetynet/src/main/java/com/google/android/gms/safetynet/HarmfulAppsInfo.java index 3b34df71a2..2c260b31ce 100644 --- a/play-services-safetynet/src/main/java/com/google/android/gms/safetynet/HarmfulAppsInfo.java +++ b/play-services-safetynet/src/main/java/com/google/android/gms/safetynet/HarmfulAppsInfo.java @@ -9,13 +9,13 @@ public class HarmfulAppsInfo extends AutoSafeParcelable { @Field(2) - public long field2; + public long lastScanTime; @Field(3) - public HarmfulAppsData[] data; + public HarmfulAppsData[] harmfulApps = new HarmfulAppsData[0]; @Field(4) - public int field4; + public int hoursSinceLastScanWithHarmfulApp = -1; @Field(5) - public boolean field5; + public boolean harmfulAppInOtherProfile = false; public static final Creator CREATOR = new AutoCreator(HarmfulAppsInfo.class); } diff --git a/play-services-safetynet/src/main/java/com/google/android/gms/safetynet/SafeBrowsingData.java b/play-services-safetynet/src/main/java/com/google/android/gms/safetynet/SafeBrowsingData.java index b14c5670d4..b73fab584c 100644 --- a/play-services-safetynet/src/main/java/com/google/android/gms/safetynet/SafeBrowsingData.java +++ b/play-services-safetynet/src/main/java/com/google/android/gms/safetynet/SafeBrowsingData.java @@ -18,17 +18,16 @@ public class SafeBrowsingData extends AutoSafeParcelable { @Field(1) public int versionCode = 1; @Field(2) - public String status; + public String metadata; @Field(3) public DataHolder data; @Field(4) public ParcelFileDescriptor fileDescriptor; - public File file; public byte[] fileContents; @Field(5) - public long field5; + public long lastUpdateTime; @Field(6) - public byte[] field6; + public byte[] state; public static final Creator CREATOR = new AutoCreator(SafeBrowsingData.class); } diff --git a/play-services-safetynet/src/main/java/org/microg/gms/safetynet/ISafetyNetCallbacksDefaultStub.java b/play-services-safetynet/src/main/java/org/microg/gms/safetynet/ISafetyNetCallbacksDefaultStub.java index cdf243bc0a..25de726592 100644 --- a/play-services-safetynet/src/main/java/org/microg/gms/safetynet/ISafetyNetCallbacksDefaultStub.java +++ b/play-services-safetynet/src/main/java/org/microg/gms/safetynet/ISafetyNetCallbacksDefaultStub.java @@ -24,7 +24,7 @@ public void onAttestationResult(Status status, AttestationData attestationData) } @Override - public void onString(String s) throws RemoteException { + public void onSharedUuid(String s) throws RemoteException { } @Override From 3e4b31bef026a91e0d3fbb54781d1dc771477caf Mon Sep 17 00:00:00 2001 From: Marvin W Date: Mon, 24 Jul 2023 00:21:18 +0200 Subject: [PATCH 04/10] Add CredentialManagerService dummy --- .../common/IPendingIntentCallback.aidl | 12 +++ .../manager/common/ISettingsCallback.aidl | 12 +++ .../internal/ICredentialManagerService.aidl | 17 ++++ .../CredentialManagerInvocationParams.aidl | 8 ++ .../manager/invocationparams/CallerInfo.java | 28 ++++++ .../CredentialManagerAccount.java | 23 +++++ .../CredentialManagerInvocationParams.java | 28 ++++++ .../org/microg/gms/common/GmsService.java | 3 + .../src/main/AndroidManifest.xml | 6 ++ .../credential/CredentialManagerService.kt | 90 +++++++++++++++++++ 10 files changed, 227 insertions(+) create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/credential/manager/common/IPendingIntentCallback.aidl create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/credential/manager/common/ISettingsCallback.aidl create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/credential/manager/firstparty/internal/ICredentialManagerService.aidl create mode 100644 play-services-api/src/main/aidl/com/google/android/gms/credential/manager/invocationparams/CredentialManagerInvocationParams.aidl create mode 100644 play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CallerInfo.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CredentialManagerAccount.java create mode 100644 play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CredentialManagerInvocationParams.java create mode 100644 play-services-core/src/main/kotlin/org/microg/gms/credential/CredentialManagerService.kt diff --git a/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/common/IPendingIntentCallback.aidl b/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/common/IPendingIntentCallback.aidl new file mode 100644 index 0000000000..7af7a04d5f --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/common/IPendingIntentCallback.aidl @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.credential.manager.common; + +import com.google.android.gms.common.api.Status; + +interface IPendingIntentCallback { + void onPendingIntent(in Status status, in PendingIntent pendingIntent); +} \ No newline at end of file diff --git a/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/common/ISettingsCallback.aidl b/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/common/ISettingsCallback.aidl new file mode 100644 index 0000000000..ef9ef410a9 --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/common/ISettingsCallback.aidl @@ -0,0 +1,12 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.credential.manager.common; + +import com.google.android.gms.common.api.Status; + +interface ISettingsCallback { + void onSetting(in Status status, in byte[] value); +} \ No newline at end of file diff --git a/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/firstparty/internal/ICredentialManagerService.aidl b/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/firstparty/internal/ICredentialManagerService.aidl new file mode 100644 index 0000000000..39ab381d2a --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/firstparty/internal/ICredentialManagerService.aidl @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.credential.manager.firstparty.internal; + +import com.google.android.gms.common.api.internal.IStatusCallback; +import com.google.android.gms.credential.manager.common.IPendingIntentCallback; +import com.google.android.gms.credential.manager.common.ISettingsCallback; +import com.google.android.gms.credential.manager.invocationparams.CredentialManagerInvocationParams; + +interface ICredentialManagerService { + void getCredentialManagerIntent(IPendingIntentCallback callback, in CredentialManagerInvocationParams params) = 0; + void getSetting(ISettingsCallback callback, String key) = 1; + void setSetting(IStatusCallback callback, String key, in byte[] value) = 2; +} \ No newline at end of file diff --git a/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/invocationparams/CredentialManagerInvocationParams.aidl b/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/invocationparams/CredentialManagerInvocationParams.aidl new file mode 100644 index 0000000000..81d43014a6 --- /dev/null +++ b/play-services-api/src/main/aidl/com/google/android/gms/credential/manager/invocationparams/CredentialManagerInvocationParams.aidl @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.credential.manager.invocationparams; + +parcelable CredentialManagerInvocationParams; \ No newline at end of file diff --git a/play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CallerInfo.java b/play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CallerInfo.java new file mode 100644 index 0000000000..85cdac1754 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CallerInfo.java @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.credential.manager.invocationparams; + +import androidx.annotation.NonNull; +import org.microg.safeparcel.AutoSafeParcelable; + +public class CallerInfo extends AutoSafeParcelable { + @Field(1) + public String s1; + @Field(2) + public String s2; + @Field(3) + public String s3; + @Field(4) + public String s4; + + @NonNull + @Override + public String toString() { + return "CallerInfo(" + s1 + "," + s2 + "," + s3 + "," + s4 + ")"; + } + + public static final Creator CREATOR = new AutoCreator<>(CallerInfo.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CredentialManagerAccount.java b/play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CredentialManagerAccount.java new file mode 100644 index 0000000000..f12db2f444 --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CredentialManagerAccount.java @@ -0,0 +1,23 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.credential.manager.invocationparams; + +import androidx.annotation.NonNull; +import org.microg.safeparcel.AutoSafeParcelable; + +public class CredentialManagerAccount extends AutoSafeParcelable { + @Field(1) + public String name; + + @NonNull + @Override + public String toString() { + return name; + } + + public static final String NAME_LOCAL = "pwm.constant.LocalAccount"; + public static final Creator CREATOR = new AutoCreator<>(CredentialManagerAccount.class); +} diff --git a/play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CredentialManagerInvocationParams.java b/play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CredentialManagerInvocationParams.java new file mode 100644 index 0000000000..871754f44c --- /dev/null +++ b/play-services-api/src/main/java/com/google/android/gms/credential/manager/invocationparams/CredentialManagerInvocationParams.java @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.google.android.gms.credential.manager.invocationparams; + +import androidx.annotation.NonNull; +import org.microg.gms.utils.ToStringHelper; +import org.microg.safeparcel.AutoSafeParcelable; + +public class CredentialManagerInvocationParams extends AutoSafeParcelable { + @Field(1) + public CredentialManagerAccount account; + @Field(2) + public CallerInfo caller; + + @NonNull + @Override + public String toString() { + return ToStringHelper.name("CredentialManagerInvocationParams") + .field("account", account) + .field("caller", caller) + .end(); + } + + public static final Creator CREATOR = new AutoCreator<>(CredentialManagerInvocationParams.class); +} diff --git a/play-services-basement/src/main/java/org/microg/gms/common/GmsService.java b/play-services-basement/src/main/java/org/microg/gms/common/GmsService.java index 5a90a3e23e..3f6541b3f4 100644 --- a/play-services-basement/src/main/java/org/microg/gms/common/GmsService.java +++ b/play-services-basement/src/main/java/org/microg/gms/common/GmsService.java @@ -119,6 +119,7 @@ public enum GmsService { CONSTELLATION(155, "com.google.android.gms.constellation.service.START"), AUDIT(154, "com.google.android.gms.audit.service.START"), SYSTEM_UPDATE(157, "com.google.android.gms.update.START_API_SERVICE"), + MOBSTORE(160, "com.google.android.mobstore.service.START"), USER_LOCATION(163, "com.google.android.gms.userlocation.service.START"), AD_HTTP(166, "com.google.android.gms.ads.service.HTTP"), LANGUAGE_PROFILE(167, "com.google.android.gms.languageprofile.service.START"), @@ -134,6 +135,7 @@ public enum GmsService { APP_USAGE(193, "com.google.android.gms.appusage.service.START"), NEARBY_SHARING_2(194, "com.google.android.gms.nearby.sharing.START_SERVICE"), AD_CONSENT_LOOKUP(195, "com.google.android.gms.ads.service.CONSENT_LOOKUP"), + CREDENTIAL_MANAGER(196, "com.google.android.gms.credential.manager.service.firstparty.START"), PHONE_INTERNAL(197, "com.google.android.gms.auth.api.phone.service.InternalService.START"), PAY(198, "com.google.android.gms.pay.service.BIND"), ASTERISM(199, "com.google.android.gms.asterism.service.START"), @@ -143,6 +145,7 @@ public enum GmsService { CONTACT_SYNC(208, "com.google.android.gms.people.contactssync.service.START"), IDENTITY_SIGN_IN(212, "com.google.android.gms.auth.api.identity.service.signin.START"), CREDENTIAL_STORE(214, "com.google.android.gms.fido.credentialstore.internal_service.START"), + MDI_SYNC(215, "com.google.android.gms.mdisync.service.START"), EVENT_ATTESTATION(216, "com.google.android.gms.ads.identifier.service.EVENT_ATTESTATION"), SCHEDULER(218, "com.google.android.gms.scheduler.ACTION_PROXY_SCHEDULE"), AUTHORIZATION(219, "com.google.android.gms.auth.api.identity.service.authorization.START"), diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index d442eb6921..d84df84d17 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -422,6 +422,12 @@ + + + + + + diff --git a/play-services-core/src/main/kotlin/org/microg/gms/credential/CredentialManagerService.kt b/play-services-core/src/main/kotlin/org/microg/gms/credential/CredentialManagerService.kt new file mode 100644 index 0000000000..447d5c2172 --- /dev/null +++ b/play-services-core/src/main/kotlin/org/microg/gms/credential/CredentialManagerService.kt @@ -0,0 +1,90 @@ +/* + * SPDX-FileCopyrightText: 2023 microG Project Team + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.credential + +import android.content.Context +import android.os.Bundle +import android.os.Parcel +import android.util.Base64 +import android.util.Log +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.lifecycleScope +import com.google.android.gms.common.ConnectionResult +import com.google.android.gms.common.Feature +import com.google.android.gms.common.api.Status +import com.google.android.gms.common.api.internal.IStatusCallback +import com.google.android.gms.common.internal.ConnectionInfo +import com.google.android.gms.common.internal.GetServiceRequest +import com.google.android.gms.common.internal.IGmsCallbacks +import com.google.android.gms.credential.manager.common.IPendingIntentCallback +import com.google.android.gms.credential.manager.common.ISettingsCallback +import com.google.android.gms.credential.manager.firstparty.internal.ICredentialManagerService +import com.google.android.gms.credential.manager.invocationparams.CredentialManagerInvocationParams +import org.microg.gms.BaseService +import org.microg.gms.common.GmsService +import org.microg.gms.common.PackageUtils +import org.microg.gms.utils.toBase64 +import org.microg.gms.utils.warnOnTransactionIssues + +private const val TAG = "CredentialManager" + +class CredentialManagerService : BaseService(TAG, GmsService.CREDENTIAL_MANAGER) { + override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService) { + if (!PackageUtils.callerHasExtendedAccess(this)) { + Log.d(TAG, "No access to ${request.packageName}, lacks permission.") + callback.onPostInitComplete(ConnectionResult.API_DISABLED_FOR_CONNECTION, null, null) + return + } + callback.onPostInitCompleteWithConnectionInfo(ConnectionResult.SUCCESS, CredentialManagerServiceImpl(this, lifecycle), ConnectionInfo().apply { + features = arrayOf( + Feature("credential_manager_first_party_api", 1), + Feature("password_checkup_first_party_api", 1), + Feature("user_service_security", 1), + ) + }) + } + +} + +private class CredentialManagerServiceImpl(private val context: Context, private val lifecycle: Lifecycle) : ICredentialManagerService.Stub(), LifecycleOwner { + override fun getLifecycle(): Lifecycle = lifecycle + + override fun getCredentialManagerIntent(callback: IPendingIntentCallback?, params: CredentialManagerInvocationParams?) { + Log.d(TAG, "Not yet implemented: getCredentialManagerIntent $params") + lifecycleScope.launchWhenStarted { + try { + callback?.onPendingIntent(Status.INTERNAL_ERROR, null) + } catch (e: Exception) { + Log.w(TAG, e) + } + } + } + + override fun getSetting(callback: ISettingsCallback?, key: String?) { + Log.d(TAG, "Not yet implemented: getSetting $key") + lifecycleScope.launchWhenStarted { + try { + callback?.onSetting(Status.INTERNAL_ERROR, null) + } catch (e: Exception) { + Log.w(TAG, e) + } + } + } + + override fun setSetting(callback: IStatusCallback?, key: String?, value: ByteArray?) { + Log.d(TAG, "Not yet implemented: setSetting $key ${value?.toBase64(Base64.NO_WRAP)}") + lifecycleScope.launchWhenStarted { + try { + callback?.onResult(Status.INTERNAL_ERROR) + } catch (e: Exception) { + Log.w(TAG, e) + } + } + } + + override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean = warnOnTransactionIssues(code, reply, flags, TAG) { super.onTransact(code, data, reply, flags) } +} \ No newline at end of file From 56b468ecbb450844c3e41a2b7d85ff979d98734b Mon Sep 17 00:00:00 2001 From: Marvin W Date: Mon, 24 Jul 2023 20:50:01 +0200 Subject: [PATCH 05/10] Stop importing android.os.Build Import fields in android.os.Build directly if really needed. Build, if ever imported, should point to our Build implementation that's populated by ProfileManager --- .../gms/firebase/auth/FirebaseAuthService.kt | 4 ++-- .../gms/common/DeviceConfiguration.java | 6 ++++-- .../gms/common/ForegroundServiceContext.java | 11 +++++----- .../org/microg/gms/common/PackageUtils.java | 2 +- .../main/kotlin/org/microg/gms/ui/Utils.kt | 4 ++-- .../android/gms/common/data/DataHolder.java | 5 +++-- .../org/microg/gms/utils/WorkSourceUtil.java | 1 - .../gms/cast/CastMediaRouteProvider.java | 1 - .../security/ProviderInstallerImpl.java | 4 ++-- .../java/org/microg/tools/ui/SwitchBar.java | 5 ++--- .../chimera/container/DynamiteContext.java | 16 +++++++++------ .../gms/auth/AccountContentProvider.java | 8 ++++---- .../java/org/microg/gms/auth/AuthManager.java | 6 +++--- .../java/org/microg/gms/gcm/GcmDatabase.java | 5 +++-- .../java/org/microg/gms/gcm/McsService.java | 19 +++++++++--------- .../gms/gservices/GServicesProvider.java | 5 +++-- .../gms/ui/AccountSettingsActivity.java | 4 ++-- .../java/org/microg/gms/ui/Conditions.java | 3 +-- .../microg/gms/ui/PlacePickerActivity.java | 4 ++-- .../org/microg/gms/ui/SelfCheckFragment.java | 3 +-- .../org/microg/gms/auth/login/FidoHandler.kt | 6 +++--- .../microg/gms/droidguard/GuardCallback.java | 5 +++-- .../internal/DroidGuardResultsRequest.java | 1 - .../core/privileged/Fido2PrivilegedService.kt | 4 ++-- .../bluetooth/BluetoothTransportHandler.kt | 4 ++-- .../screenlock/ScreenLockCredentialStore.kt | 4 ++-- .../screenlock/ScreenLockTransportHandler.kt | 4 ++-- .../gms/fido/core/ui/AuthenticatorActivity.kt | 8 ++++---- .../gms/fido/core/ui/NfcTransportFragment.kt | 4 ++-- .../gms/fido/core/ui/UsbTransportFragment.kt | 6 +++--- .../gms/fido/core/ui/WelcomeFragment.kt | 1 - .../google/android/gms/gcm/GcmReceiver.java | 4 ++-- .../android/gms/iid/MessengerCompat.java | 5 ++--- .../org/microg/gms/iid/InstanceIdRpc.java | 4 ++-- .../gms/location/network/wifi/extensions.kt | 4 ++-- .../microg/gms/location/manager/extensions.kt | 1 - .../ui/LocationPreferencesFragment.kt | 6 +++--- .../exposurenotification/AdvertiserService.kt | 10 +++++----- .../nearby/exposurenotification/DeviceInfo.kt | 20 ++++++++++--------- .../ExposureNotificationService.kt | 4 ++-- .../exposurenotification/NotifyService.kt | 14 ++++++------- .../exposurenotification/ui/DotChartView.kt | 4 ++-- .../ExposureNotificationsConfirmActivity.kt | 14 ++++++------- .../ui/ExposureNotificationsFragment.kt | 4 ++-- .../gms/recaptcha/RecaptchaGuardImpl.kt | 4 ++-- .../microg/gms/safetynet/SafetyNetDatabase.kt | 4 ++-- 46 files changed, 134 insertions(+), 131 deletions(-) diff --git a/firebase-auth/core/src/main/kotlin/org/microg/gms/firebase/auth/FirebaseAuthService.kt b/firebase-auth/core/src/main/kotlin/org/microg/gms/firebase/auth/FirebaseAuthService.kt index 2916c0fec0..d5af19cada 100644 --- a/firebase-auth/core/src/main/kotlin/org/microg/gms/firebase/auth/FirebaseAuthService.kt +++ b/firebase-auth/core/src/main/kotlin/org/microg/gms/firebase/auth/FirebaseAuthService.kt @@ -9,7 +9,7 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Handler import android.os.Parcel import android.provider.Telephony @@ -62,7 +62,7 @@ private val UserProfileChangeRequest.deleteAttributeList: List } private fun Intent.getSmsMessages(): Array { - return if (Build.VERSION.SDK_INT >= 19) { + return if (SDK_INT >= 19) { Telephony.Sms.Intents.getMessagesFromIntent(this) } else { (getSerializableExtra("pdus") as? Array)?.map { SmsMessage.createFromPdu(it) }.orEmpty().toTypedArray() diff --git a/play-services-base/core/src/main/java/org/microg/gms/common/DeviceConfiguration.java b/play-services-base/core/src/main/java/org/microg/gms/common/DeviceConfiguration.java index 411de8aa84..98e334aad4 100644 --- a/play-services-base/core/src/main/java/org/microg/gms/common/DeviceConfiguration.java +++ b/play-services-base/core/src/main/java/org/microg/gms/common/DeviceConfiguration.java @@ -23,8 +23,9 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.opengl.GLES10; -import android.os.Build; import android.util.DisplayMetrics; +import org.microg.gms.profile.Build; +import org.microg.gms.profile.ProfileManager; import java.util.ArrayList; import java.util.Arrays; @@ -56,6 +57,7 @@ public class DeviceConfiguration { public int widthPixels; public DeviceConfiguration(Context context) { + ProfileManager.ensureInitialized(context); ConfigurationInfo configurationInfo = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getDeviceConfigurationInfo(); touchScreen = configurationInfo.reqTouchScreen; keyboardType = configurationInfo.reqKeyboardType; @@ -101,7 +103,7 @@ public DeviceConfiguration(Context context) { @SuppressWarnings({"deprecation", "InlinedApi"}) private static List getNativePlatforms() { List nativePlatforms; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT >= 21) { return Arrays.asList(Build.SUPPORTED_ABIS); } else { nativePlatforms = new ArrayList(); diff --git a/play-services-base/core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java b/play-services-base/core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java index 3e17ca29ce..dc00dc702b 100644 --- a/play-services-base/core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java +++ b/play-services-base/core/src/main/java/org/microg/gms/common/ForegroundServiceContext.java @@ -8,7 +8,6 @@ import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; -import android.os.Build; import android.os.PowerManager; import android.util.Log; @@ -16,6 +15,8 @@ import org.microg.gms.base.core.R; +import static android.os.Build.VERSION.SDK_INT; + public class ForegroundServiceContext extends ContextWrapper { private static final String TAG = "ForegroundService"; public static final String EXTRA_FOREGROUND = "foreground"; @@ -26,7 +27,7 @@ public ForegroundServiceContext(Context base) { @Override public ComponentName startService(Intent service) { - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isIgnoringBatteryOptimizations()) { + if (SDK_INT >= 26 && !isIgnoringBatteryOptimizations()) { Log.d(TAG, "Starting in foreground mode."); service.putExtra(EXTRA_FOREGROUND, true); return super.startForegroundService(service); @@ -34,7 +35,7 @@ public ComponentName startService(Intent service) { return super.startService(service); } - @RequiresApi(api = Build.VERSION_CODES.M) + @RequiresApi(23) private boolean isIgnoringBatteryOptimizations() { PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); return powerManager.isIgnoringBatteryOptimizations(getPackageName()); @@ -64,7 +65,7 @@ private static String getServiceName(Service service) { } public static void completeForegroundService(Service service, Intent intent, String tag) { - if (intent != null && intent.getBooleanExtra(EXTRA_FOREGROUND, false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (intent != null && intent.getBooleanExtra(EXTRA_FOREGROUND, false) && SDK_INT >= 26) { String serviceName = getServiceName(service); Log.d(tag, "Started " + serviceName + " in foreground mode."); try { @@ -77,7 +78,7 @@ public static void completeForegroundService(Service service, Intent intent, Str } } - @RequiresApi(api = Build.VERSION_CODES.O) + @RequiresApi(26) private static Notification buildForegroundNotification(Context context, String serviceName) { NotificationChannel channel = new NotificationChannel("foreground-service", "Foreground Service", NotificationManager.IMPORTANCE_NONE); channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET); 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 9f0e96c41a..f30fdf3aa8 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 @@ -271,7 +271,7 @@ public static String firstPackageFromUserId(Context context, int uid) { @SuppressWarnings("deprecation") public static String packageFromPendingIntent(PendingIntent pi) { if (pi == null) return null; - if (SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (SDK_INT < 17) { return pi.getTargetPackage(); } else { return pi.getCreatorPackage(); diff --git a/play-services-base/core/src/main/kotlin/org/microg/gms/ui/Utils.kt b/play-services-base/core/src/main/kotlin/org/microg/gms/ui/Utils.kt index 5df78d3d76..2994a039bb 100644 --- a/play-services-base/core/src/main/kotlin/org/microg/gms/ui/Utils.kt +++ b/play-services-base/core/src/main/kotlin/org/microg/gms/ui/Utils.kt @@ -8,7 +8,7 @@ package org.microg.gms.ui import android.content.Context import android.content.pm.ApplicationInfo import android.content.pm.PackageManager -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.provider.Settings import android.util.Log @@ -47,7 +47,7 @@ val Context.systemAnimationsEnabled: Boolean get() { val duration: Float val transition: Float - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (SDK_INT >= 17) { duration = Settings.Global.getFloat(contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f) transition = Settings.Global.getFloat(contentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE, 1f) } else { diff --git a/play-services-base/src/main/java/com/google/android/gms/common/data/DataHolder.java b/play-services-base/src/main/java/com/google/android/gms/common/data/DataHolder.java index 2867e4139d..79902d34c1 100644 --- a/play-services-base/src/main/java/com/google/android/gms/common/data/DataHolder.java +++ b/play-services-base/src/main/java/com/google/android/gms/common/data/DataHolder.java @@ -23,7 +23,6 @@ import android.database.Cursor; import android.database.CursorWindow; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Parcel; @@ -38,6 +37,8 @@ import java.util.List; import java.util.Map; +import static android.os.Build.VERSION.SDK_INT; + /** * Class for accessing collections of data, organized into columns. This provides the backing * support for DataBuffer. Much like a cursor, the holder supports the notion of a current @@ -155,7 +156,7 @@ public static DataHolder empty(int statusCode) { @SuppressWarnings("deprecation") @SuppressLint({"NewApi", "ObsoleteSdkInt"}) static int getCursorType(Cursor cursor, int i) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + if (SDK_INT >= 11) { return cursor.getType(i); } if (cursor instanceof AbstractWindowedCursor) { diff --git a/play-services-basement/src/main/java/org/microg/gms/utils/WorkSourceUtil.java b/play-services-basement/src/main/java/org/microg/gms/utils/WorkSourceUtil.java index 78689b5a5e..419800b92b 100644 --- a/play-services-basement/src/main/java/org/microg/gms/utils/WorkSourceUtil.java +++ b/play-services-basement/src/main/java/org/microg/gms/utils/WorkSourceUtil.java @@ -5,7 +5,6 @@ package org.microg.gms.utils; -import android.os.Build; import android.os.WorkSource; import android.util.Log; diff --git a/play-services-cast/core/src/main/java/org/microg/gms/cast/CastMediaRouteProvider.java b/play-services-cast/core/src/main/java/org/microg/gms/cast/CastMediaRouteProvider.java index 0b1e3a8600..52f48aeb0c 100644 --- a/play-services-cast/core/src/main/java/org/microg/gms/cast/CastMediaRouteProvider.java +++ b/play-services-cast/core/src/main/java/org/microg/gms/cast/CastMediaRouteProvider.java @@ -22,7 +22,6 @@ import android.net.Uri; import android.net.nsd.NsdManager; import android.net.nsd.NsdServiceInfo; -import android.os.Build; import android.os.Bundle; import android.os.AsyncTask; import android.os.Handler; diff --git a/play-services-conscrypt-provider-core/src/main/java/com/google/android/gms/common/security/ProviderInstallerImpl.java b/play-services-conscrypt-provider-core/src/main/java/com/google/android/gms/common/security/ProviderInstallerImpl.java index 587d8158ce..67a65f8605 100644 --- a/play-services-conscrypt-provider-core/src/main/java/com/google/android/gms/common/security/ProviderInstallerImpl.java +++ b/play-services-conscrypt-provider-core/src/main/java/com/google/android/gms/common/security/ProviderInstallerImpl.java @@ -7,7 +7,6 @@ import android.content.Context; import android.content.pm.ApplicationInfo; -import android.os.Build; import android.os.Process; import android.util.Log; @@ -38,6 +37,7 @@ import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; +import static android.os.Build.VERSION.SDK_INT; import static com.google.android.gms.security.ProviderInstaller.PROVIDER_NAME; @Keep @@ -58,7 +58,7 @@ private static String getRealSelfPackageName(Context context) { } catch (Exception e) { } - if (Build.VERSION.SDK_INT >= 29) { + if (SDK_INT >= 29) { return context.getOpPackageName(); } Context applicationContext = context.getApplicationContext(); diff --git a/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBar.java b/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBar.java index ab282dd50c..2d63313d16 100644 --- a/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBar.java +++ b/play-services-core/microg-ui-tools/src/main/java/org/microg/tools/ui/SwitchBar.java @@ -18,7 +18,6 @@ package org.microg.tools.ui; import android.content.Context; -import android.os.Build; import android.os.Parcel; import android.os.Parcelable; import android.text.SpannableStringBuilder; @@ -70,7 +69,7 @@ public SwitchBar(Context context, AttributeSet attrs) { LayoutInflater.from(context).inflate(R.layout.switch_bar, this); mTextView = (TextView) findViewById(R.id.switch_text); - if (SDK_INT > Build.VERSION_CODES.JELLY_BEAN) { + if (SDK_INT > 16) { mTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); } mLabel = getResources().getString(R.string.abc_capital_off); @@ -81,7 +80,7 @@ public SwitchBar(Context context, AttributeSet attrs) { // Prevent onSaveInstanceState() to be called as we are managing the state of the Switch // on our own mSwitch.setSaveEnabled(false); - if (SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + if (SDK_INT >= 16) { mSwitch.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); } diff --git a/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteContext.java b/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteContext.java index 8484447b2b..cbc93d2777 100644 --- a/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteContext.java +++ b/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteContext.java @@ -9,7 +9,6 @@ import android.content.ContextWrapper; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; -import android.os.Build; import android.os.Process; import android.util.Log; @@ -21,6 +20,11 @@ import dalvik.system.PathClassLoader; +import static android.os.Build.CPU_ABI; +import static android.os.Build.SUPPORTED_32_BIT_ABIS; +import static android.os.Build.SUPPORTED_64_BIT_ABIS; +import static android.os.Build.VERSION.SDK_INT; + public class DynamiteContext extends ContextWrapper { private static final String TAG = "DynamiteContext"; private DynamiteModuleInfo moduleInfo; @@ -42,16 +46,16 @@ public DynamiteContext(DynamiteModuleInfo moduleInfo, Context base, Context gmsC public ClassLoader getClassLoader() { if (classLoader == null) { StringBuilder nativeLoaderDirs = new StringBuilder(gmsContext.getApplicationInfo().nativeLibraryDir); - if (Build.VERSION.SDK_INT >= 23 && Process.is64Bit()) { - for (String abi : Build.SUPPORTED_64_BIT_ABIS) { + if (SDK_INT >= 23 && Process.is64Bit()) { + for (String abi : SUPPORTED_64_BIT_ABIS) { nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(abi); } - } else if (Build.VERSION.SDK_INT >= 21) { - for (String abi : Build.SUPPORTED_32_BIT_ABIS) { + } else if (SDK_INT >= 21) { + for (String abi : SUPPORTED_32_BIT_ABIS) { nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(abi); } } else { - nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(Build.CPU_ABI); + nativeLoaderDirs.append(File.pathSeparator).append(gmsContext.getApplicationInfo().sourceDir).append("!/lib/").append(CPU_ABI); } classLoader = new PathClassLoader(gmsContext.getApplicationInfo().sourceDir, nativeLoaderDirs.toString(), new FilteredClassLoader(originalContext.getClassLoader(), moduleInfo.getMergedClasses(), moduleInfo.getMergedPackages())); } diff --git a/play-services-core/src/main/java/org/microg/gms/auth/AccountContentProvider.java b/play-services-core/src/main/java/org/microg/gms/auth/AccountContentProvider.java index 57581a00e9..036bc8e581 100644 --- a/play-services-core/src/main/java/org/microg/gms/auth/AccountContentProvider.java +++ b/play-services-core/src/main/java/org/microg/gms/auth/AccountContentProvider.java @@ -27,7 +27,6 @@ import android.database.Cursor; import android.net.Uri; import android.os.Binder; -import android.os.Build; import android.os.Bundle; import android.util.Log; @@ -37,6 +36,7 @@ import java.util.Arrays; +import static android.os.Build.VERSION.SDK_INT; import static org.microg.gms.auth.AuthConstants.DEFAULT_ACCOUNT_TYPE; import static org.microg.gms.auth.AuthConstants.PROVIDER_EXTRA_ACCOUNTS; import static org.microg.gms.auth.AuthConstants.PROVIDER_EXTRA_CLEAR_PASSWORD; @@ -55,7 +55,7 @@ public boolean onCreate() { @Override public Bundle call(String method, String arg, Bundle extras) { String suggestedPackageName = null; - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { + if (SDK_INT > 19) { suggestedPackageName = getCallingPackage(); } String packageName = PackageUtils.getAndCheckCallingPackage(getContext(), suggestedPackageName); @@ -73,13 +73,13 @@ public Bundle call(String method, String arg, Bundle extras) { Account[] accounts = null; if (arg != null && (arg.equals(DEFAULT_ACCOUNT_TYPE) || arg.startsWith(DEFAULT_ACCOUNT_TYPE + "."))) { AccountManager am = AccountManager.get(getContext()); - if (Build.VERSION.SDK_INT >= 18) { + if (SDK_INT >= 18) { accounts = am.getAccountsByTypeForPackage(arg, packageName); } if (accounts == null || accounts.length == 0) { accounts = am.getAccountsByType(arg); } - if (Build.VERSION.SDK_INT >= 26 && accounts != null && arg.equals(DEFAULT_ACCOUNT_TYPE)) { + if (SDK_INT >= 26 && accounts != null && arg.equals(DEFAULT_ACCOUNT_TYPE)) { for (Account account : accounts) { if (am.getAccountVisibility(account, packageName) == AccountManager.VISIBILITY_UNDEFINED) { Log.d(TAG, "Make account " + account + " visible to " + packageName); diff --git a/play-services-core/src/main/java/org/microg/gms/auth/AuthManager.java b/play-services-core/src/main/java/org/microg/gms/auth/AuthManager.java index 5b8282cf9c..8ba6c6a939 100644 --- a/play-services-core/src/main/java/org/microg/gms/auth/AuthManager.java +++ b/play-services-core/src/main/java/org/microg/gms/auth/AuthManager.java @@ -20,7 +20,6 @@ import android.accounts.AccountManager; import android.content.Context; import android.content.pm.PackageManager; -import android.os.Build; import android.util.Log; import org.microg.gms.common.PackageUtils; @@ -30,6 +29,7 @@ import static android.content.pm.ApplicationInfo.FLAG_SYSTEM; import static android.content.pm.ApplicationInfo.FLAG_UPDATED_SYSTEM_APP; +import static android.os.Build.VERSION.SDK_INT; import static org.microg.gms.auth.AuthPrefs.isTrustGooglePermitted; public class AuthManager { @@ -93,7 +93,7 @@ public String buildPermKey() { public void setPermitted(boolean value) { setUserData(buildPermKey(), value ? "1" : "0"); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && value && packageName != null) { + if (SDK_INT >= 26 && value && packageName != null) { // Make account persistently visible as we already granted access accountManager.setAccountVisibility(getAccount(), packageName, AccountManager.VISIBILITY_VISIBLE); } @@ -161,7 +161,7 @@ public void setAuthToken(String auth) { public void setAuthToken(String service, String auth) { getAccountManager().setAuthToken(getAccount(), buildTokenKey(service), auth); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && packageName != null && auth != null) { + if (SDK_INT >= 26 && packageName != null && auth != null) { // Make account persistently visible as we already granted access accountManager.setAccountVisibility(getAccount(), packageName, AccountManager.VISIBILITY_VISIBLE); } 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 ce32d8d3db..4762797206 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 @@ -10,13 +10,14 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; -import android.os.Build; import android.text.TextUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import static android.os.Build.VERSION.SDK_INT; + public class GcmDatabase extends SQLiteOpenHelper { private static final String TAG = GcmDatabase.class.getSimpleName(); public static final String DB_NAME = "gcmstatus"; @@ -55,7 +56,7 @@ public class GcmDatabase extends SQLiteOpenHelper { public GcmDatabase(Context context) { super(context, DB_NAME, null, DB_VERSION); this.context = context; - if (Build.VERSION.SDK_INT >= 16) { + if (SDK_INT >= 16) { this.setWriteAheadLoggingEnabled(true); } } 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 a0858a8dea..c0ce947f10 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 @@ -28,7 +28,6 @@ import android.content.pm.ResolveInfo; import android.net.ConnectivityManager; import android.net.NetworkInfo; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -137,10 +136,10 @@ public class McsService extends Service implements Handler.Callback { @Nullable private Method addPowerSaveTempWhitelistAppMethod; @Nullable - @RequiresApi(Build.VERSION_CODES.S) + @RequiresApi(31) private Object powerExemptionManager; @Nullable - @RequiresApi(Build.VERSION_CODES.S) + @RequiresApi(31) private Method addToTemporaryAllowListMethod; private class HandlerThread extends Thread { @@ -178,9 +177,9 @@ public void onCreate() { heartbeatIntent = PendingIntent.getService(this, 0, new Intent(ACTION_HEARTBEAT, null, this, McsService.class), 0); alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); powerManager = (PowerManager) getSystemService(POWER_SERVICE); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission("android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST") == PackageManager.PERMISSION_GRANTED) { + if (SDK_INT >= 23 && checkSelfPermission("android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST") == PackageManager.PERMISSION_GRANTED) { try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + if (SDK_INT >= 31) { Class powerExemptionManagerClass = Class.forName("android.os.PowerExemptionManager"); powerExemptionManager = getSystemService(powerExemptionManagerClass); addToTemporaryAllowListMethod = @@ -267,7 +266,7 @@ public static void scheduleReconnect(Context context) { long delay = getCurrentDelay(); logd(context, "Scheduling reconnect in " + delay / 1000 + " seconds..."); PendingIntent pi = PendingIntent.getBroadcast(context, 1, new Intent(ACTION_RECONNECT, null, context, TriggerReceiver.class), 0); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (SDK_INT >= 23) { alarmManager.setExactAndAllowWhileIdle(ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, pi); } else { alarmManager.set(ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delay, pi); @@ -282,10 +281,10 @@ public void scheduleHeartbeat(Context context) { closeAll(); } logd(context, "Scheduling heartbeat in " + heartbeatMs / 1000 + " seconds..."); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (SDK_INT >= 23) { // This is supposed to work even when running in idle and without battery optimization disabled alarmManager.setExactAndAllowWhileIdle(ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + heartbeatMs, heartbeatIntent); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + } else if (SDK_INT >= 19) { // With KitKat, the alarms become inexact by default, but with the newly available setWindow we can get inexact alarms with guarantees. // Schedule the alarm to fire within the interval [heartbeatMs/3*4, heartbeatMs] alarmManager.setWindow(ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + heartbeatMs / 4 * 3, heartbeatMs / 4, @@ -606,7 +605,7 @@ private void handleAppMessage(DataMessageStanza msg) { } private void addPowerSaveTempWhitelistApp(String packageName) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + if (SDK_INT >= 31) { try { if (addToTemporaryAllowListMethod != null && powerExemptionManager != null) { logd(this, "Adding app " + packageName + " to the temp allowlist"); @@ -615,7 +614,7 @@ private void addPowerSaveTempWhitelistApp(String packageName) { } catch (Exception e) { Log.e(TAG, "Error adding app" + packageName + " to the temp allowlist.", e); } - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + } else if (SDK_INT >= 23) { try { if (getUserIdMethod != null && addPowerSaveTempWhitelistAppMethod != null && deviceIdleController != null) { int userId = (int) getUserIdMethod.invoke(null, getPackageManager().getApplicationInfo(packageName, 0).uid); diff --git a/play-services-core/src/main/java/org/microg/gms/gservices/GServicesProvider.java b/play-services-core/src/main/java/org/microg/gms/gservices/GServicesProvider.java index 0dc21d3016..b0cb1e049f 100644 --- a/play-services-core/src/main/java/org/microg/gms/gservices/GServicesProvider.java +++ b/play-services-core/src/main/java/org/microg/gms/gservices/GServicesProvider.java @@ -21,7 +21,6 @@ import android.database.Cursor; import android.database.MatrixCursor; import android.net.Uri; -import android.os.Build; import android.util.Log; import java.util.HashMap; @@ -30,6 +29,8 @@ import java.util.Map; import java.util.Set; +import static android.os.Build.VERSION.SDK_INT; + /** * Originally found in Google Services Framework (com.google.android.gsf), this provides a generic * key-value store, that is written by the checkin service and read from various Google Apps. @@ -56,7 +57,7 @@ public boolean onCreate() { } private String getCallingPackageName() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + if (SDK_INT >= 19) { return getCallingPackage(); } else { return "unknown"; diff --git a/play-services-core/src/main/java/org/microg/gms/ui/AccountSettingsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/AccountSettingsActivity.java index 491b720109..e1e1dd5a6b 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/AccountSettingsActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/AccountSettingsActivity.java @@ -18,7 +18,6 @@ import android.accounts.Account; import android.accounts.AccountManager; -import android.os.Build; import android.os.Bundle; import androidx.annotation.Nullable; @@ -34,6 +33,7 @@ import static android.accounts.AccountManager.PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE; import static android.accounts.AccountManager.VISIBILITY_NOT_VISIBLE; import static android.accounts.AccountManager.VISIBILITY_VISIBLE; +import static android.os.Build.VERSION.SDK_INT; import static org.microg.gms.auth.AuthManager.PREF_AUTH_VISIBLE; public class AccountSettingsActivity extends AbstractSettingsActivity { @@ -53,7 +53,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, String root super.onCreatePreferences(savedInstanceState, rootKey); Preference pref = findPreference(PREF_AUTH_VISIBLE); if (pref != null) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { + if (SDK_INT < 26) { pref.setVisible(false); } else { pref.setOnPreferenceChangeListener((preference, newValue) -> { diff --git a/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java b/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java index de517dc5c2..6e295cc333 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/Conditions.java @@ -20,7 +20,6 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; -import android.os.Build; import android.os.PowerManager; import android.provider.Settings; import android.view.View; @@ -74,7 +73,7 @@ public void onClick(View v) { @Override public boolean isActive(Context context) { count = 0; - if (SDK_INT >= Build.VERSION_CODES.M) { + if (SDK_INT >= 23) { for (String permission : REQUIRED_PERMISSIONS) { if (ContextCompat.checkSelfPermission(context, permission) != PERMISSION_GRANTED) count++; diff --git a/play-services-core/src/main/java/org/microg/gms/ui/PlacePickerActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/PlacePickerActivity.java index e9563348ca..a86104443a 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/PlacePickerActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/PlacePickerActivity.java @@ -21,7 +21,6 @@ import android.location.Geocoder; import android.location.Location; import android.location.LocationManager; -import android.os.Build; import android.os.Bundle; import android.text.Html; import android.text.TextUtils; @@ -60,6 +59,7 @@ import static android.Manifest.permission.ACCESS_COARSE_LOCATION; import static android.Manifest.permission.ACCESS_FINE_LOCATION; import static android.content.pm.PackageManager.PERMISSION_GRANTED; +import static android.os.Build.VERSION.SDK_INT; import static org.microg.gms.location.LocationConstants.EXTRA_PRIMARY_COLOR; import static org.microg.gms.location.LocationConstants.EXTRA_PRIMARY_COLOR_DARK; //import static org.microg.gms.maps.vtm.GmsMapsTypeHelper.fromLatLngBounds; @@ -90,7 +90,7 @@ protected void onCreate(Bundle savedInstanceState) { if (getIntent().hasExtra(EXTRA_PRIMARY_COLOR)) { toolbar.setBackgroundColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR, 0)); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + if (SDK_INT >= 21) getWindow().setStatusBarColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0)); ((TextView) findViewById(R.id.place_picker_title)).setTextColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0)); } diff --git a/play-services-core/src/main/java/org/microg/gms/ui/SelfCheckFragment.java b/play-services-core/src/main/java/org/microg/gms/ui/SelfCheckFragment.java index 77c8303da2..8ebbff9a62 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/SelfCheckFragment.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/SelfCheckFragment.java @@ -22,7 +22,6 @@ import android.content.pm.PermissionGroupInfo; import android.content.pm.PermissionInfo; import android.net.Uri; -import android.os.Build; import android.provider.Settings; import android.util.Log; import android.view.LayoutInflater; @@ -96,7 +95,7 @@ public void doChecks(Context context, ResultCollector collector) { } }); } - if (SDK_INT >= Build.VERSION_CODES.M) { + if (SDK_INT >= 23) { checks.add(new SystemChecks()); } // checks.add(new NlpOsCompatChecks()); diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/login/FidoHandler.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/login/FidoHandler.kt index bcc07012e0..24a12116a0 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/auth/login/FidoHandler.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/login/FidoHandler.kt @@ -5,7 +5,7 @@ package org.microg.gms.auth.login -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.util.Base64 import android.util.Log @@ -34,8 +34,8 @@ class FidoHandler(private val activity: LoginActivity) : TransportHandlerCallbac setOfNotNull( BluetoothTransportHandler(activity, this), NfcTransportHandler(activity, this), - if (Build.VERSION.SDK_INT >= 21) UsbTransportHandler(activity, this) else null, - if (Build.VERSION.SDK_INT >= 23) ScreenLockTransportHandler(activity, this) else null + if (SDK_INT >= 21) UsbTransportHandler(activity, this) else null, + if (SDK_INT >= 23) ScreenLockTransportHandler(activity, this) else null ) } diff --git a/play-services-droidguard/core/src/main/java/org/microg/gms/droidguard/GuardCallback.java b/play-services-droidguard/core/src/main/java/org/microg/gms/droidguard/GuardCallback.java index 3fc81e7993..eb4f8890fe 100644 --- a/play-services-droidguard/core/src/main/java/org/microg/gms/droidguard/GuardCallback.java +++ b/play-services-droidguard/core/src/main/java/org/microg/gms/droidguard/GuardCallback.java @@ -7,7 +7,6 @@ import android.content.Context; import android.media.MediaDrm; -import android.os.Build; import android.util.Log; import org.microg.gms.droidguard.core.FallbackCreator; @@ -15,6 +14,8 @@ import java.util.HashMap; +import static android.os.Build.VERSION.SDK_INT; + /** * Callbacks invoked from the DroidGuard VM *

@@ -60,7 +61,7 @@ public final String c() { public final void d(final Object mediaDrm, final byte[] sessionId) { Log.d(TAG, "d[closeMediaDrmSession](" + mediaDrm + ", " + sessionId + ")"); synchronized (MediaDrmLock.LOCK) { - if (Build.VERSION.SDK_INT >= 18) { + if (SDK_INT >= 18) { ((MediaDrm) mediaDrm).closeSession(sessionId); } } diff --git a/play-services-droidguard/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.java b/play-services-droidguard/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.java index 2f011a5f7d..d2f0948b5e 100644 --- a/play-services-droidguard/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.java +++ b/play-services-droidguard/src/main/java/com/google/android/gms/droidguard/internal/DroidGuardResultsRequest.java @@ -6,7 +6,6 @@ package com.google.android.gms.droidguard.internal; import android.net.Network; -import android.os.Build; import android.os.Bundle; import android.os.ParcelFileDescriptor; diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/privileged/Fido2PrivilegedService.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/privileged/Fido2PrivilegedService.kt index 23bbcc8539..c57c24a864 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/privileged/Fido2PrivilegedService.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/privileged/Fido2PrivilegedService.kt @@ -12,7 +12,7 @@ import android.app.PendingIntent.FLAG_UPDATE_CURRENT import android.content.Context import android.content.Context.KEYGUARD_SERVICE import android.content.Intent -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Parcel import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner @@ -90,7 +90,7 @@ class Fido2PrivilegedServiceImpl(private val context: Context, private val lifec override fun isUserVerifyingPlatformAuthenticatorAvailable(callbacks: IBooleanCallback) { lifecycleScope.launchWhenStarted { - if (Build.VERSION.SDK_INT < 24) { + if (SDK_INT < 24) { callbacks.onBoolean(false) } else { val keyguardManager = context.getSystemService(KEYGUARD_SERVICE) as? KeyguardManager? diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/bluetooth/BluetoothTransportHandler.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/bluetooth/BluetoothTransportHandler.kt index 050e5fe9b6..c6e00b0279 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/bluetooth/BluetoothTransportHandler.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/bluetooth/BluetoothTransportHandler.kt @@ -7,7 +7,7 @@ package org.microg.gms.fido.core.transport.bluetooth import android.bluetooth.BluetoothManager import android.content.Context -import android.os.Build +import android.os.Build.VERSION.SDK_INT import androidx.core.content.getSystemService import org.microg.gms.fido.core.transport.Transport import org.microg.gms.fido.core.transport.TransportHandler @@ -16,5 +16,5 @@ import org.microg.gms.fido.core.transport.TransportHandlerCallback class BluetoothTransportHandler(private val context: Context, callback: TransportHandlerCallback? = null) : TransportHandler(Transport.BLUETOOTH, callback) { override val isSupported: Boolean - get() = Build.VERSION.SDK_INT >= 18 && context.getSystemService()?.adapter != null + get() = SDK_INT >= 18 && context.getSystemService()?.adapter != null } diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/screenlock/ScreenLockCredentialStore.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/screenlock/ScreenLockCredentialStore.kt index fa536be821..7a0f1cdb5d 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/screenlock/ScreenLockCredentialStore.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/screenlock/ScreenLockCredentialStore.kt @@ -8,7 +8,7 @@ package org.microg.gms.fido.core.transport.screenlock import android.content.Context import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.security.keystore.KeyGenParameterSpec import android.security.keystore.KeyPermanentlyInvalidatedException import android.security.keystore.KeyProperties @@ -40,7 +40,7 @@ class ScreenLockCredentialStore(val context: Context) { .setDigests(KeyProperties.DIGEST_SHA256) .setAlgorithmParameterSpec(ECGenParameterSpec("secp256r1")) .setUserAuthenticationRequired(true) - if (Build.VERSION.SDK_INT >= 24) builder.setAttestationChallenge(challenge) + if (SDK_INT >= 24) builder.setAttestationChallenge(challenge) generator.initialize(builder.build()) generator.generateKeyPair() return keyId diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/screenlock/ScreenLockTransportHandler.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/screenlock/ScreenLockTransportHandler.kt index 9bfbfb8974..de518add46 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/screenlock/ScreenLockTransportHandler.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/transport/screenlock/ScreenLockTransportHandler.kt @@ -6,7 +6,7 @@ package org.microg.gms.fido.core.transport.screenlock import android.app.KeyguardManager -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.util.Log import androidx.annotation.RequiresApi import androidx.biometric.BiometricPrompt @@ -134,7 +134,7 @@ class ScreenLockTransportHandler(private val activity: FragmentActivity, callbac NoneAttestationObject(authenticatorData) } else { try { - if (Build.VERSION.SDK_INT >= 24) { + if (SDK_INT >= 24) { createAndroidKeyAttestation(signature, authenticatorData, clientDataHash, options.rpId, keyId) } else { createSafetyNetAttestation(authenticatorData, clientDataHash) diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/AuthenticatorActivity.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/AuthenticatorActivity.kt index e894e344f9..1f1b79b7d8 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/AuthenticatorActivity.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/AuthenticatorActivity.kt @@ -8,7 +8,7 @@ package org.microg.gms.fido.core.ui import android.content.Intent import android.graphics.Color import android.graphics.drawable.ColorDrawable -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.util.Base64 import android.util.Log @@ -60,8 +60,8 @@ class AuthenticatorActivity : AppCompatActivity(), TransportHandlerCallback { setOfNotNull( BluetoothTransportHandler(this, this), NfcTransportHandler(this, this), - if (Build.VERSION.SDK_INT >= 21) UsbTransportHandler(this, this) else null, - if (Build.VERSION.SDK_INT >= 23) ScreenLockTransportHandler(this, this) else null + if (SDK_INT >= 21) UsbTransportHandler(this, this) else null, + if (SDK_INT >= 23) ScreenLockTransportHandler(this, this) else null ) } @@ -84,7 +84,7 @@ class AuthenticatorActivity : AppCompatActivity(), TransportHandlerCallback { if (!intent.extras?.keySet().orEmpty().containsAll(REQUIRED_EXTRAS)) { return finishWithError(UNKNOWN_ERR, "Extra missing from request") } - if (Build.VERSION.SDK_INT < 24) { + if (SDK_INT < 24) { return finishWithError(NOT_SUPPORTED_ERR, "FIDO2 API is not supported on devices below N") } val options = options ?: return finishWithError(DATA_ERR, "The request options are not valid") diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/NfcTransportFragment.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/NfcTransportFragment.kt index 75b6b4c311..1640807899 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/NfcTransportFragment.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/NfcTransportFragment.kt @@ -8,7 +8,7 @@ package org.microg.gms.fido.core.ui import android.graphics.drawable.Animatable2 import android.graphics.drawable.AnimatedVectorDrawable import android.graphics.drawable.Drawable -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -38,7 +38,7 @@ class NfcTransportFragment : AuthenticatorActivityFragment(), TransportHandlerCa navOptions { popUpTo(R.id.usbFragment) { inclusive = true } }) } } - if (Build.VERSION.SDK_INT >= 23) { + if (SDK_INT >= 23) { (binding.fidoNfcWaitConnectAnimation.drawable as? AnimatedVectorDrawable)?.registerAnimationCallback(object : Animatable2.AnimationCallback() { override fun onAnimationEnd(drawable: Drawable?) { diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/UsbTransportFragment.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/UsbTransportFragment.kt index 8ca1705479..42f8c9f3de 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/UsbTransportFragment.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/UsbTransportFragment.kt @@ -10,7 +10,7 @@ import android.graphics.drawable.AnimatedVectorDrawable import android.graphics.drawable.Drawable import android.hardware.usb.UsbDevice import android.hardware.usb.UsbManager -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.util.Log import android.view.LayoutInflater @@ -42,7 +42,7 @@ class UsbTransportFragment : AuthenticatorActivityFragment(), TransportHandlerCa navOptions { popUpTo(R.id.usbFragment) { inclusive = true } }) } } - if (Build.VERSION.SDK_INT >= 23) { + if (SDK_INT >= 23) { for (imageView in listOfNotNull(binding.fidoUsbWaitConnectAnimation, binding.fidoUsbWaitConfirmAnimation)) { (imageView.drawable as? AnimatedVectorDrawable)?.registerAnimationCallback(object : Animatable2.AnimationCallback() { override fun onAnimationEnd(drawable: Drawable?) { @@ -63,7 +63,7 @@ class UsbTransportFragment : AuthenticatorActivityFragment(), TransportHandlerCa override fun onStatusChanged(transport: Transport, status: String, extras: Bundle?) { if (transport != Transport.USB) return binding.status = status - if (Build.VERSION.SDK_INT >= 21) { + if (SDK_INT >= 21) { binding.deviceName = extras?.getParcelable(UsbManager.EXTRA_DEVICE)?.productName ?: "your security key" } else { diff --git a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/WelcomeFragment.kt b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/WelcomeFragment.kt index af15b910f5..4d9071cde4 100644 --- a/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/WelcomeFragment.kt +++ b/play-services-fido/core/src/main/kotlin/org/microg/gms/fido/core/ui/WelcomeFragment.kt @@ -5,7 +5,6 @@ package org.microg.gms.fido.core.ui -import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View diff --git a/play-services-gcm/src/main/java/com/google/android/gms/gcm/GcmReceiver.java b/play-services-gcm/src/main/java/com/google/android/gms/gcm/GcmReceiver.java index e9bba44b9e..1df70bccb0 100644 --- a/play-services-gcm/src/main/java/com/google/android/gms/gcm/GcmReceiver.java +++ b/play-services-gcm/src/main/java/com/google/android/gms/gcm/GcmReceiver.java @@ -23,11 +23,11 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; -import android.os.Build; import android.util.Base64; import android.util.Log; import androidx.legacy.content.WakefulBroadcastReceiver; +import static android.os.Build.VERSION.SDK_INT; import static org.microg.gms.gcm.GcmConstants.ACTION_C2DM_REGISTRATION; import static org.microg.gms.gcm.GcmConstants.ACTION_INSTANCE_ID; import static org.microg.gms.gcm.GcmConstants.EXTRA_FROM; @@ -69,7 +69,7 @@ public void onReceive(Context context, Intent intent) { private void sanitizeIntent(Context context, Intent intent) { intent.setComponent(null); intent.setPackage(context.getPackageName()); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { + if (SDK_INT < 19) { intent.removeCategory(context.getPackageName()); } String from = intent.getStringExtra(EXTRA_FROM); diff --git a/play-services-iid/src/main/java/com/google/android/gms/iid/MessengerCompat.java b/play-services-iid/src/main/java/com/google/android/gms/iid/MessengerCompat.java index 05bf4c8c0f..5e397e515d 100644 --- a/play-services-iid/src/main/java/com/google/android/gms/iid/MessengerCompat.java +++ b/play-services-iid/src/main/java/com/google/android/gms/iid/MessengerCompat.java @@ -26,14 +26,13 @@ import android.os.RemoteException; import static android.os.Build.VERSION.SDK_INT; -import static android.os.Build.VERSION_CODES.LOLLIPOP; public class MessengerCompat implements Parcelable { private Messenger messenger; private IMessengerCompat messengerCompat; public MessengerCompat(IBinder binder) { - if (SDK_INT >= LOLLIPOP) { + if (SDK_INT >= 21) { messenger = new Messenger(binder); } else { messengerCompat = IMessengerCompat.Stub.asInterface(binder); @@ -41,7 +40,7 @@ public MessengerCompat(IBinder binder) { } public MessengerCompat(Handler handler) { - if (SDK_INT >= LOLLIPOP) { + if (SDK_INT >= 21) { messenger = new Messenger(handler); } else { messengerCompat = new IMessengerCompatImpl(handler); diff --git a/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java b/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java index cce6616f4f..2f3f660301 100644 --- a/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java +++ b/play-services-iid/src/main/java/org/microg/gms/iid/InstanceIdRpc.java @@ -22,7 +22,6 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.os.Build; import android.os.Bundle; import android.os.ConditionVariable; import android.os.Handler; @@ -51,6 +50,7 @@ import java.util.Random; import static android.content.pm.PackageManager.PERMISSION_GRANTED; +import static android.os.Build.VERSION.SDK_INT; import static com.google.android.gms.iid.InstanceID.ERROR_BACKOFF; import static com.google.android.gms.iid.InstanceID.ERROR_MISSING_INSTANCEID_SERVICE; import static com.google.android.gms.iid.InstanceID.ERROR_SERVICE_NOT_AVAILABLE; @@ -281,7 +281,7 @@ private void sendRegisterMessage(Bundle data, KeyPair keyPair, String requestId) Intent intent = new Intent(ACTION_C2DM_REGISTER); intent.setPackage(iidPackageName); data.putString(EXTRA_GMS_VERSION, Integer.toString(getGmsVersionCode(context))); - data.putString(EXTRA_OS_VERSION, Integer.toString(Build.VERSION.SDK_INT)); + data.putString(EXTRA_OS_VERSION, Integer.toString(SDK_INT)); data.putString(EXTRA_APP_VERSION_CODE, Integer.toString(getSelfVersionCode(context))); data.putString(EXTRA_APP_VERSION_NAME, getSelfVersionName(context)); data.putString(EXTRA_CLIENT_VERSION, "iid-" + GMS_VERSION_CODE); diff --git a/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/extensions.kt b/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/extensions.kt index 2d5617261a..ff05dfa67a 100644 --- a/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/extensions.kt +++ b/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/extensions.kt @@ -6,13 +6,13 @@ package org.microg.gms.location.network.wifi import android.net.wifi.ScanResult -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.SystemClock internal fun ScanResult.toWifiDetails(): WifiDetails = WifiDetails( macAddress = BSSID, ssid = SSID, - timestamp = if (Build.VERSION.SDK_INT >= 19) System.currentTimeMillis() - (SystemClock.elapsedRealtime() - (timestamp / 1000)) else null, + timestamp = if (SDK_INT >= 19) System.currentTimeMillis() - (SystemClock.elapsedRealtime() - (timestamp / 1000)) else null, frequency = frequency, channel = frequencyToChannel(frequency), signalStrength = level, diff --git a/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/extensions.kt b/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/extensions.kt index bd518bd085..9780ee17bb 100644 --- a/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/extensions.kt +++ b/play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/extensions.kt @@ -10,7 +10,6 @@ import android.app.AppOpsManager import android.content.Context import android.content.pm.PackageManager import android.os.Binder -import android.os.Build import android.os.Build.VERSION.SDK_INT import android.os.Process import android.os.WorkSource diff --git a/play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationPreferencesFragment.kt b/play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationPreferencesFragment.kt index ccb3cace90..99b02de86c 100644 --- a/play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationPreferencesFragment.kt +++ b/play-services-location/core/src/main/kotlin/org/microg/gms/location/ui/LocationPreferencesFragment.kt @@ -6,7 +6,7 @@ package org.microg.gms.location.ui import android.annotation.SuppressLint -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Bundle import androidx.core.os.bundleOf import androidx.lifecycle.lifecycleScope @@ -90,8 +90,8 @@ class LocationPreferencesFragment : PreferenceFragmentCompat() { networkProviderCategory.isVisible = requireContext().hasNetworkLocationServiceBuiltIn() wifiMls.isVisible = requireContext().hasMozillaLocationServiceSupport() cellMls.isVisible = requireContext().hasMozillaLocationServiceSupport() - wifiLearning.isVisible = Build.VERSION.SDK_INT >= 17 - cellLearning.isVisible = Build.VERSION.SDK_INT >= 17 + wifiLearning.isVisible = SDK_INT >= 17 + cellLearning.isVisible = SDK_INT >= 17 } override fun onResume() { 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 da9228fb51..bdd3701873 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 @@ -19,7 +19,7 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Handler import android.os.Looper import android.os.SystemClock @@ -142,7 +142,7 @@ class AdvertiserService : LifecycleService() { } val data = AdvertiseData.Builder().addServiceUuid(SERVICE_UUID).addServiceData(SERVICE_UUID, payload).build() Log.i(TAG, "Starting advertiser") - if (Build.VERSION.SDK_INT >= 26) { + if (SDK_INT >= 26) { setCallback = SetCallback() val params = AdvertisingSetParameters.Builder() .setInterval(AdvertisingSetParameters.INTERVAL_MEDIUM) @@ -201,7 +201,7 @@ class AdvertiserService : LifecycleService() { val intent = Intent(this, AdvertiserService::class.java).apply { action = ACTION_RESTART_ADVERTISING } val pendingIntent = PendingIntent.getService(this, ACTION_RESTART_ADVERTISING.hashCode(), intent, FLAG_ONE_SHOT or FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE) when { - Build.VERSION.SDK_INT >= 23 -> + SDK_INT >= 23 -> alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + nextSend, pendingIntent) else -> alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + nextSend, pendingIntent) @@ -214,7 +214,7 @@ class AdvertiserService : LifecycleService() { if (!advertising) return Log.i(TAG, "Stopping advertiser") advertising = false - if (Build.VERSION.SDK_INT >= 26) { + if (SDK_INT >= 26) { wantStartAdvertising = true try { advertiser?.stopAdvertisingSet(setCallback as AdvertisingSetCallback) @@ -259,7 +259,7 @@ class AdvertiserService : LifecycleService() { val adapter = getDefaultAdapter() return when { adapter == null -> false - Build.VERSION.SDK_INT >= 26 && (adapter.isLeExtendedAdvertisingSupported || adapter.isLePeriodicAdvertisingSupported) -> true + SDK_INT >= 26 && (adapter.isLeExtendedAdvertisingSupported || adapter.isLePeriodicAdvertisingSupported) -> true adapter.state != STATE_ON -> null adapter.bluetoothLeAdvertiser != null -> true else -> false diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/DeviceInfo.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/DeviceInfo.kt index cb18b8b5c3..226264f163 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/DeviceInfo.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/DeviceInfo.kt @@ -8,7 +8,9 @@ package org.microg.gms.nearby.exposurenotification -import android.os.Build +import android.os.Build.DEVICE +import android.os.Build.MANUFACTURER +import android.os.Build.MODEL import android.util.Log import com.google.android.gms.nearby.exposurenotification.CalibrationConfidence import kotlin.math.roundToInt @@ -25,10 +27,10 @@ val currentDeviceInfo: DeviceInfo var deviceInfo = knownDeviceInfo if (deviceInfo == null) { // Note: Custom ROMs sometimes have slightly different model information, so we have some flexibility for those - val byOem = allDeviceInfos.filter { it.oem.equalsIgnoreCase(Build.MANUFACTURER) } - val byDevice = allDeviceInfos.filter { it.device.equalsIgnoreCase(Build.DEVICE) } - val byModel = allDeviceInfos.filter { it.model.equalsIgnoreCase(Build.MODEL) } - val exactMatch = byOem.find { it.device.equalsIgnoreCase(Build.DEVICE) && it.model.equalsIgnoreCase(Build.MODEL) } + val byOem = allDeviceInfos.filter { it.oem.equalsIgnoreCase(MANUFACTURER) } + val byDevice = allDeviceInfos.filter { it.device.equalsIgnoreCase(DEVICE) } + val byModel = allDeviceInfos.filter { it.model.equalsIgnoreCase(MODEL) } + val exactMatch = byOem.find { it.device.equalsIgnoreCase(DEVICE) && it.model.equalsIgnoreCase(MODEL) } deviceInfo = when { exactMatch != null -> { // Exact match, use provided confidence @@ -36,15 +38,15 @@ val currentDeviceInfo: DeviceInfo } byModel.isNotEmpty() || byDevice.isNotEmpty() -> { // We have data from "sister devices", that's way better than taking the OEM average - averageCurrentDeviceInfo(Build.MANUFACTURER, Build.DEVICE, Build.MODEL, (byDevice + byModel).distinct(), CalibrationConfidence.MEDIUM) + averageCurrentDeviceInfo(MANUFACTURER, DEVICE, MODEL, (byDevice + byModel).distinct(), CalibrationConfidence.MEDIUM) } byOem.isNotEmpty() -> { // Fallback to OEM average - averageCurrentDeviceInfo(Build.MANUFACTURER, Build.DEVICE, Build.MODEL, byOem, CalibrationConfidence.LOW) + averageCurrentDeviceInfo(MANUFACTURER, DEVICE, MODEL, byOem, CalibrationConfidence.LOW) } else -> { // Fallback to all device average - averageCurrentDeviceInfo(Build.MANUFACTURER, Build.DEVICE, Build.MODEL, allDeviceInfos, CalibrationConfidence.LOWEST) + averageCurrentDeviceInfo(MANUFACTURER, DEVICE, MODEL, allDeviceInfos, CalibrationConfidence.LOWEST) } } Log.i(TAG, "Selected $deviceInfo") @@ -54,7 +56,7 @@ val currentDeviceInfo: DeviceInfo } val averageDeviceInfo: DeviceInfo - get() = averageCurrentDeviceInfo(Build.MANUFACTURER, Build.DEVICE, Build.MODEL, allDeviceInfos, CalibrationConfidence.LOWEST) + get() = averageCurrentDeviceInfo(MANUFACTURER, DEVICE, MODEL, allDeviceInfos, CalibrationConfidence.LOWEST) @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") private fun String.equalsIgnoreCase(other: String): Boolean = (this as java.lang.String).equalsIgnoreCase(other) diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationService.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationService.kt index d862340867..f40ced3bf0 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationService.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationService.kt @@ -6,7 +6,7 @@ package org.microg.gms.nearby.exposurenotification import android.content.pm.PackageManager -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.util.Log import com.google.android.gms.common.Feature import com.google.android.gms.common.internal.ConnectionInfo @@ -33,7 +33,7 @@ class ExposureNotificationService : BaseService(TAG, GmsService.NEARBY_EXPOSURE) checkPermission("android.permission.BLUETOOTH") ?: return } - if (Build.VERSION.SDK_INT < 21) { + if (SDK_INT < 21) { callback.onPostInitComplete(FAILED_NOT_SUPPORTED, null, null) return } diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/NotifyService.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/NotifyService.kt index d05d777066..6207db6ee8 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/NotifyService.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/NotifyService.kt @@ -17,7 +17,7 @@ import android.content.IntentFilter import android.content.pm.PackageManager import android.graphics.Color import android.location.LocationManager -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.util.Log import android.util.TypedValue import androidx.core.app.NotificationCompat @@ -45,7 +45,7 @@ class NotifyService : LifecycleService() { channel.setSound(null, null) channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC channel.setShowBadge(true) - if (Build.VERSION.SDK_INT >= 29) { + if (SDK_INT >= 29) { channel.setAllowBubbles(false) } channel.vibrationPattern = longArrayOf(0) @@ -58,7 +58,7 @@ class NotifyService : LifecycleService() { val location = !LocationManagerCompat.isLocationEnabled(getSystemService(Context.LOCATION_SERVICE) as LocationManager) val bluetooth = BluetoothAdapter.getDefaultAdapter()?.state.let { it != BluetoothAdapter.STATE_ON && it != BluetoothAdapter.STATE_TURNING_ON } val nearbyPermissions = arrayOf("android.permission.BLUETOOTH_ADVERTISE", "android.permission.BLUETOOTH_SCAN") - val permissionNeedsHandling = Build.VERSION.SDK_INT >= 31 && nearbyPermissions.any { + val permissionNeedsHandling = SDK_INT >= 31 && nearbyPermissions.any { ContextCompat.checkSelfPermission(this, it) != PackageManager.PERMISSION_GRANTED } Log.d( TAG,"notify: location: $location, bluetooth: $bluetooth, permissionNeedsHandling: $permissionNeedsHandling") @@ -74,7 +74,7 @@ class NotifyService : LifecycleService() { } } - if (Build.VERSION.SDK_INT >= 26) { + if (SDK_INT >= 26) { NotificationCompat.Builder(this, createNotificationChannel()) } else { NotificationCompat.Builder(this) @@ -82,13 +82,13 @@ class NotifyService : LifecycleService() { val typedValue = TypedValue() try { var resolved = theme.resolveAttribute(androidx.appcompat.R.attr.colorError, typedValue, true) - if (!resolved && Build.VERSION.SDK_INT >= 26) resolved = theme.resolveAttribute(android.R.attr.colorError, typedValue, true) + if (!resolved && SDK_INT >= 26) resolved = theme.resolveAttribute(android.R.attr.colorError, typedValue, true) color = if (resolved) { ContextCompat.getColor(this@NotifyService, typedValue.resourceId) } else { Color.RED } - if (Build.VERSION.SDK_INT >= 26) setColorized(true) + if (SDK_INT >= 26) setColorized(true) } catch (e: Exception) { // Ignore } @@ -112,7 +112,7 @@ class NotifyService : LifecycleService() { super.onCreate() registerReceiver(trigger, IntentFilter().apply { addAction(BluetoothAdapter.ACTION_STATE_CHANGED) - if (Build.VERSION.SDK_INT >= 19) addAction(LocationManager.MODE_CHANGED_ACTION) + if (SDK_INT >= 19) addAction(LocationManager.MODE_CHANGED_ACTION) addAction(LocationManager.PROVIDERS_CHANGED_ACTION) addAction(NOTIFICATION_UPDATE_ACTION) }) diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/DotChartView.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/DotChartView.kt index 47aa534457..ba9f13ada7 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/DotChartView.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/DotChartView.kt @@ -9,7 +9,7 @@ import android.annotation.SuppressLint import android.annotation.TargetApi import android.content.Context import android.graphics.* -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.text.format.DateFormat import android.text.format.DateUtils import android.util.AttributeSet @@ -194,7 +194,7 @@ class DotChartView : View { 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) { + if (focusHour != -1 && SDK_INT >= 23) { val floatingColor = context.resolveColor(androidx.appcompat.R.attr.colorBackgroundFloating) ?: 0 val line1 = "${displayData[focusDay]?.first}, $focusHour:00" val line2 = displayData[focusDay]?.second?.get(focusHour)?.let { context.getString(R.string.pref_exposure_rpis_histogram_legend_records, it.toString()) } diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/ExposureNotificationsConfirmActivity.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/ExposureNotificationsConfirmActivity.kt index db6a737516..e202dbf536 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/ExposureNotificationsConfirmActivity.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/ExposureNotificationsConfirmActivity.kt @@ -14,7 +14,7 @@ import android.content.pm.PackageInfo.REQUESTED_PERMISSION_NEVER_FOR_LOCATION import android.content.pm.PackageManager import android.content.pm.PackageManager.PERMISSION_GRANTED import android.location.LocationManager -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.os.ResultReceiver import android.provider.Settings @@ -116,7 +116,7 @@ class ExposureNotificationsConfirmActivity : AppCompatActivity() { private var permissionRequestCode = 33 private fun getRequiredPermissions(): Array { return when { - Build.VERSION.SDK_INT >= 31 -> { + SDK_INT >= 31 -> { // We only need bluetooth permission on 31+ if it's "strongly asserted" that we won't use bluetooth for // location. Otherwise, we also need LOCATION permissions. See // https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location @@ -136,7 +136,7 @@ class ExposureNotificationsConfirmActivity : AppCompatActivity() { ACCESS_FINE_LOCATION ) } - Build.VERSION.SDK_INT == 29 -> { + SDK_INT == 29 -> { // We only can directly request background location permission on 29. // We need it on 30 (and possibly later) as well, but it has to be requested in a two // step process, see https://fosstodon.org/@utf8equalsX/104359649537615235 @@ -158,11 +158,11 @@ class ExposureNotificationsConfirmActivity : AppCompatActivity() { private fun checkPermissions() { val permissions = getRequiredPermissions() - permissionNeedsHandling = Build.VERSION.SDK_INT >= 23 && permissions.any { + permissionNeedsHandling = SDK_INT >= 23 && permissions.any { checkSelfPermission(this, it) != PERMISSION_GRANTED } - backgroundLocationNeedsHandling = Build.VERSION.SDK_INT >= 30 + backgroundLocationNeedsHandling = SDK_INT >= 30 && ACCESS_FINE_LOCATION in permissions && checkSelfPermission(this, ACCESS_FINE_LOCATION) == PERMISSION_GRANTED && checkSelfPermission(this, ACCESS_BACKGROUND_LOCATION) != PERMISSION_GRANTED @@ -175,13 +175,13 @@ class ExposureNotificationsConfirmActivity : AppCompatActivity() { } private fun requestPermissions() { - if (Build.VERSION.SDK_INT >= 23) { + if (SDK_INT >= 23) { requestPermissions(getRequiredPermissions(), ++permissionRequestCode) } } private fun requestBackgroundLocation() { - if (Build.VERSION.SDK_INT >= 29) { + if (SDK_INT >= 29) { requestPermissions(arrayOf(ACCESS_BACKGROUND_LOCATION), ++permissionRequestCode) } } diff --git a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/ExposureNotificationsFragment.kt b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/ExposureNotificationsFragment.kt index ac9489fa16..379a25aa3e 100644 --- a/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/ExposureNotificationsFragment.kt +++ b/play-services-nearby/core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ui/ExposureNotificationsFragment.kt @@ -11,7 +11,7 @@ import android.content.Context.LOCATION_SERVICE import android.content.Intent import android.content.pm.PackageManager import android.location.LocationManager -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.Bundle import android.os.Handler import android.provider.Settings @@ -144,7 +144,7 @@ class ExposureNotificationsFragment : PreferenceFragmentCompat() { val nearbyPermissions = arrayOf("android.permission.BLUETOOTH_ADVERTISE", "android.permission.BLUETOOTH_SCAN") // Expresses implication (API 31+ → all new permissions granted) ≡ (¬API 31+ | all new permissions granted) - val nearbyPermissionsGranted = Build.VERSION.SDK_INT < 31 || nearbyPermissions.all { + val nearbyPermissionsGranted = SDK_INT < 31 || nearbyPermissions.all { ContextCompat.checkSelfPermission(appContext, it) == PackageManager.PERMISSION_GRANTED } exposureNearbyNotGranted.isVisible = enabled && !nearbyPermissionsGranted diff --git a/play-services-recaptcha/core/src/main/kotlin/org/microg/gms/recaptcha/RecaptchaGuardImpl.kt b/play-services-recaptcha/core/src/main/kotlin/org/microg/gms/recaptcha/RecaptchaGuardImpl.kt index 297ccbcdb2..6494ff94a9 100644 --- a/play-services-recaptcha/core/src/main/kotlin/org/microg/gms/recaptcha/RecaptchaGuardImpl.kt +++ b/play-services-recaptcha/core/src/main/kotlin/org/microg/gms/recaptcha/RecaptchaGuardImpl.kt @@ -6,7 +6,7 @@ package org.microg.gms.recaptcha import android.content.Context -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.os.LocaleList import android.util.Log import com.android.volley.* @@ -94,7 +94,7 @@ class ProtobufPostRequest, O>(url: String, private val i: I, p override fun getHeaders(): Map { val headers = HashMap(super.getHeaders()) - headers["Accept-Language"] = if (Build.VERSION.SDK_INT >= 24) LocaleList.getDefault().toLanguageTags() else Locale.getDefault().language + headers["Accept-Language"] = if (SDK_INT >= 24) LocaleList.getDefault().toLanguageTags() else Locale.getDefault().language return headers } diff --git a/play-services-safetynet/core/src/main/kotlin/org/microg/gms/safetynet/SafetyNetDatabase.kt b/play-services-safetynet/core/src/main/kotlin/org/microg/gms/safetynet/SafetyNetDatabase.kt index eb60aaffad..1a3d7ce0cb 100644 --- a/play-services-safetynet/core/src/main/kotlin/org/microg/gms/safetynet/SafetyNetDatabase.kt +++ b/play-services-safetynet/core/src/main/kotlin/org/microg/gms/safetynet/SafetyNetDatabase.kt @@ -9,14 +9,14 @@ import android.content.Context import android.database.Cursor import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper -import android.os.Build +import android.os.Build.VERSION.SDK_INT import android.util.Log import com.google.android.gms.common.api.Status class SafetyNetDatabase(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) { init { - if (Build.VERSION.SDK_INT >= 16) { + if (SDK_INT >= 16) { setWriteAheadLoggingEnabled(true) } } From 9ce0e43ba9316b69e0f8675e610cdaa575bf26ad Mon Sep 17 00:00:00 2001 From: Marvin W Date: Tue, 1 Aug 2023 15:47:15 +0200 Subject: [PATCH 06/10] Maps: Force queueing getMapAsync callback, if it's already requested from such a callback Prevents infinite recursion in some apps --- .../kotlin/org/microg/gms/maps/mapbox/GoogleMap.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 48d3f5503f..8140370a7d 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 @@ -63,6 +63,7 @@ import org.microg.gms.maps.mapbox.model.* import org.microg.gms.maps.mapbox.utils.MultiArchLoader import org.microg.gms.maps.mapbox.utils.toGms import org.microg.gms.maps.mapbox.utils.toMapbox +import java.util.concurrent.atomic.AtomicBoolean private fun LongSparseArray.values() = (0 until size()).mapNotNull { valueAt(it) } @@ -853,6 +854,7 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG tryRunUserInitializedCallbacks("getMapAsync") } + private var isInvokingInitializedCallbacks = AtomicBoolean(false) fun tryRunUserInitializedCallbacks(tag: String = "") { synchronized(mapLock) { @@ -876,8 +878,12 @@ class GoogleMapImpl(context: Context, var options: GoogleMapOptions) : AbstractG val map = map if (initialized && map != null) { // Call all callbacks immediately, as map is ready - Log.d("$TAG:$tag", "Invoking callback instantly, as map is initialized") - runCallbacks() + Log.d("$TAG:$tag", "Invoking callback now, as map is initialized") + val wasCallbackActive = isInvokingInitializedCallbacks.getAndSet(true) + runOnMainLooper(forceQueue = wasCallbackActive) { + runCallbacks() + } + if (!wasCallbackActive) isInvokingInitializedCallbacks.set(false) } else if (mapView?.isShown == false) { /* If map is hidden, an app (e.g. Dott) may expect it to initialize anyway and * will not show the map until it is initialized. However, we should not call From 62c445aa35c13e00510a28ae87c779ca020e0050 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 11 Aug 2023 10:11:00 +0200 Subject: [PATCH 07/10] Location: Improve moving wifi support --- .../src/main/AndroidManifest.xml | 1 + .../main/res/xml/network_security_config.xml | 11 ++++ .../location/network/wifi/MovingWifiHelper.kt | 55 ++++++++++++++++++- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 play-services-core/src/main/res/xml/network_security_config.xml diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml index d84df84d17..67c9bf79cb 100644 --- a/play-services-core/src/main/AndroidManifest.xml +++ b/play-services-core/src/main/AndroidManifest.xml @@ -117,6 +117,7 @@ android:icon="@mipmap/ic_core_service_app" android:label="@string/gms_app_name" android:multiArch="true" + android:networkSecurityConfig="@xml/network_security_config" android:theme="@style/Theme.AppCompat.DayNight"> diff --git a/play-services-core/src/main/res/xml/network_security_config.xml b/play-services-core/src/main/res/xml/network_security_config.xml new file mode 100644 index 0000000000..6d264fb1ca --- /dev/null +++ b/play-services-core/src/main/res/xml/network_security_config.xml @@ -0,0 +1,11 @@ + + + + + + portal.mav.hu + + \ No newline at end of file diff --git a/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/MovingWifiHelper.kt b/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/MovingWifiHelper.kt index fdf896fc8c..821c0a5b82 100644 --- a/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/MovingWifiHelper.kt +++ b/play-services-location/core/provider/src/main/kotlin/org/microg/gms/location/network/wifi/MovingWifiHelper.kt @@ -35,6 +35,7 @@ private val MOVING_WIFI_HOTSPOTS = setOf( // France "_SNCF_WIFI_INOUI", "_SNCF_WIFI_INTERCITES", + "_WIFI_LYRIA", "OUIFI", "NormandieTrainConnecte", // Germany @@ -42,16 +43,24 @@ private val MOVING_WIFI_HOTSPOTS = setOf( "WIFI@DB", "WiFi@DB", "RRX Hotspot", + "FlixBux", "FlixBus Wi-Fi", + "FlixTrain Wi-Fi", "FlyNet", "Telekom_FlyNet", "Vestische WLAN", // Greece "AegeanWiFi", + // Hong Kong + "Cathay Pacific", // Hungary "MAVSTART-WIFI", // Netherlands "KEOLIS Nederland", + // Sweden + "SJ", + // Switzerland + "SBB-Free", // United Kingdom "CrossCountryWiFi", "GWR WiFi", @@ -170,13 +179,52 @@ class MovingWifiHelper(private val context: Context) { return location } + private fun parsePanasonic(location: Location, data: ByteArray): Location { + val json = JSONObject(data.decodeToString()) + location.accuracy = 100f + location.latitude = json.getJSONObject("current_coordinates").getDouble("latitude") + location.longitude = json.getJSONObject("current_coordinates").getDouble("longitude") + json.optDouble("ground_speed_knots").takeIf { !it.isNaN() }?.let { + location.speed = (it * 0.5144).toFloat() + LocationCompat.setSpeedAccuracyMetersPerSecond(location, location.speed * 0.1f) + } + json.optDouble("altitude_feet").takeIf { !it.isNaN() }?.let { location.altitude = it * 0.3048 } + json.optDouble("true_heading_degree").takeIf { !it.isNaN() }?.let { + location.bearing = it.toFloat() + LocationCompat.setBearingAccuracyDegrees(location, 90f) + } + return location + } + + private fun parseBoardConnect(location: Location, data: ByteArray): Location { + val json = JSONObject(data.decodeToString()) + location.accuracy = 100f + location.latitude = json.getDouble("lat") + location.longitude = json.getDouble("lon") + runCatching { SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US).parse(json.getString("utc"))?.time }.getOrNull()?.let { location.time = it } + json.optDouble("groundSpeed").takeIf { !it.isNaN() }?.let { + location.speed = (it * 0.5144).toFloat() + LocationCompat.setSpeedAccuracyMetersPerSecond(location, location.speed * 0.1f) + } + json.optDouble("altitude").takeIf { !it.isNaN() }?.let { location.altitude = it * 0.3048 } + json.optDouble("heading").takeIf { !it.isNaN() }?.let { + location.bearing = it.toFloat() + LocationCompat.setBearingAccuracyDegrees(location, 90f) + } + return location + } + private fun parseInput(ssid: String, data: ByteArray): Location { val location = Location(ssid) return when (ssid) { "WIFIonICE" -> parseWifiOnIce(location, data) + "FlixBus" -> parseFlixbus(location, data) "FlixBus Wi-Fi" -> parseFlixbus(location, data) + "FlixTrain Wi-Fi" -> parseFlixbus(location, data) "MAVSTART-WIFI" -> parsePassengera(location, data) "AegeanWiFi" -> parseDisplayUgo(location, data) + "Telekom_FlyNet" -> parsePanasonic(location, data) + "FlyNet" -> parseBoardConnect(location, data) else -> throw UnsupportedOperationException() } } @@ -187,9 +235,14 @@ class MovingWifiHelper(private val context: Context) { companion object { private val MOVING_WIFI_HOTSPOTS_LOCALLY_RETRIEVABLE = mapOf( "WIFIonICE" to "https://iceportal.de/api1/rs/status", + "FlixBus" to "https://media.flixbus.com/services/pis/v1/position", "FlixBus Wi-Fi" to "https://media.flixbus.com/services/pis/v1/position", + "FlixTrain Wi-Fi" to "https://media.flixbus.com/services/pis/v1/position", "MAVSTART-WIFI" to "http://portal.mav.hu/portal/api/vehicle/realtime", - "AegeanWiFi" to "https://api.ife.ugo.aero/navigation/positions" + "AegeanWiFi" to "https://api.ife.ugo.aero/navigation/positions", + "Telekom_FlyNet" to "https://services.inflightpanasonic.aero/inflight/services/flightdata/v2/flightdata", + "Cathay Pacific" to "https://services.inflightpanasonic.aero/inflight/services/flightdata/v2/flightdata", + "FlyNet" to "https://ww2.lufthansa-flynet.com/map/api/flightData", ) } } From d48238de9bcd658b902775ac5b2557db897b225d Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 11 Aug 2023 10:11:38 +0200 Subject: [PATCH 08/10] Ads: return empty version string in MobileAdsSettingManager Fixed #2004 --- .../kotlin/org/microg/gms/ads/MobileAdsSettingManagerImpl.kt | 4 ++++ .../gms/ads/internal/client/IMobileAdsSettingManager.aidl | 1 + 2 files changed, 5 insertions(+) diff --git a/play-services-ads-lite/core/src/main/kotlin/org/microg/gms/ads/MobileAdsSettingManagerImpl.kt b/play-services-ads-lite/core/src/main/kotlin/org/microg/gms/ads/MobileAdsSettingManagerImpl.kt index 53e5997f54..4620a4b1ad 100644 --- a/play-services-ads-lite/core/src/main/kotlin/org/microg/gms/ads/MobileAdsSettingManagerImpl.kt +++ b/play-services-ads-lite/core/src/main/kotlin/org/microg/gms/ads/MobileAdsSettingManagerImpl.kt @@ -49,6 +49,10 @@ class MobileAdsSettingManagerImpl(private val context: Context?) : IMobileAdsSet return true } + override fun getVersionString(): String { + return "" + } + override fun registerRtbAdapter(className: String?) { Log.d(TAG, "registerRtbAdapter($className)") } diff --git a/play-services-ads-lite/src/main/aidl/com/google/android/gms/ads/internal/client/IMobileAdsSettingManager.aidl b/play-services-ads-lite/src/main/aidl/com/google/android/gms/ads/internal/client/IMobileAdsSettingManager.aidl index af9f5c3791..aaf02a56f6 100644 --- a/play-services-ads-lite/src/main/aidl/com/google/android/gms/ads/internal/client/IMobileAdsSettingManager.aidl +++ b/play-services-ads-lite/src/main/aidl/com/google/android/gms/ads/internal/client/IMobileAdsSettingManager.aidl @@ -14,6 +14,7 @@ interface IMobileAdsSettingManager { void fetchAppSettings(String appId, IObjectWrapper runnable) = 5; float getAdVolume() = 6; boolean isAdMuted() = 7; + String getVersionString() = 8; void registerRtbAdapter(String className) = 9; void addInitializationCallback(IInitializationCallback callback) = 11; List getAdapterStatus() = 12; From 2d1395936836ae81d680736bc2175bb691d20b53 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Fri, 11 Aug 2023 10:13:39 +0200 Subject: [PATCH 09/10] Base: add support for Build.VERSION.DEVICE_INITIAL_SDK_INT to profile manager --- .../core/src/main/kotlin/org/microg/gms/profile/Build.kt | 3 +++ .../main/kotlin/org/microg/gms/profile/ProfileManager.kt | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/play-services-base/core/src/main/kotlin/org/microg/gms/profile/Build.kt b/play-services-base/core/src/main/kotlin/org/microg/gms/profile/Build.kt index a52059a911..a40e1792be 100644 --- a/play-services-base/core/src/main/kotlin/org/microg/gms/profile/Build.kt +++ b/play-services-base/core/src/main/kotlin/org/microg/gms/profile/Build.kt @@ -90,6 +90,9 @@ object Build { @JvmField var SECURITY_PATCH: String? = null + + @JvmField + var DEVICE_INITIAL_SDK_INT: Int = 0 } fun generateWebViewUserAgentString(original: String): String { diff --git a/play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt b/play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt index 56b313e5d6..65eb5684f9 100644 --- a/play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt +++ b/play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt @@ -202,6 +202,7 @@ object ProfileManager { return serial } + @SuppressLint("BlockedPrivateApi") private fun getRealData(): Map = mutableMapOf( "Build.BOARD" to android.os.Build.BOARD, "Build.BOOTLOADER" to android.os.Build.BOOTLOADER, @@ -235,6 +236,12 @@ object ProfileManager { if (android.os.Build.VERSION.SDK_INT >= 23) { put("Build.VERSION.SECURITY_PATCH", android.os.Build.VERSION.SECURITY_PATCH) } + try { + val field = android.os.Build.VERSION::class.java.getDeclaredField("DEVICE_INITIAL_SDK_INT") + field.isAccessible = true + put("Build.VERSION.DEVICE_INITIAL_SDK_INT", field.getInt(null).toString()) + } catch (ignored: Exception) { + } } private fun applyProfileData(profileData: Map) { @@ -267,6 +274,7 @@ object ProfileManager { applyStringField("Build.VERSION.RELEASE") { Build.VERSION.RELEASE = it } applyStringField("Build.VERSION.SDK") { Build.VERSION.SDK = it } applyIntField("Build.VERSION.SDK_INT") { Build.VERSION.SDK_INT = it } + applyIntField("Build.VERSION.DEVICE_INITIAL_SDK_INT") { Build.VERSION.DEVICE_INITIAL_SDK_INT = it } if (android.os.Build.VERSION.SDK_INT >= 21) { Build.SUPPORTED_ABIS = profileData["Build.SUPPORTED_ABIS"]?.split(",")?.toTypedArray() ?: emptyArray() } else { From 4651ed55308f2113b0ada49884dd320165dc5e10 Mon Sep 17 00:00:00 2001 From: ale5000 <15793015+ale5000-git@users.noreply.github.com> Date: Sun, 13 Aug 2023 20:36:08 +0200 Subject: [PATCH 10/10] Allow to compress the libraries (#2000) --- play-services-core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play-services-core/build.gradle b/play-services-core/build.gradle index 88615a87a4..f3aaae36df 100644 --- a/play-services-core/build.gradle +++ b/play-services-core/build.gradle @@ -160,7 +160,7 @@ android { packagingOptions { exclude 'META-INF/ASL2.0' jniLibs { - useLegacyPackaging false + useLegacyPackaging true } } }