diff --git a/build.gradle b/build.gradle index 8558d6c3..63d96ee5 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.1.2' + classpath 'com.android.tools.build:gradle:4.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" classpath "com.squareup.wire:wire-gradle-plugin:$wireVersion" } @@ -45,8 +45,8 @@ allprojects { apply plugin: 'idea' group = 'org.microg.gms' - version = "0.2.18.210390" - ext.appVersionCode = 210390001 + version = "0.2.18.210500" + ext.appVersionCode = 210500001 ext.isReleaseVersion = false } diff --git a/play-services-base/src/main/java/com/google/android/gms/common/GoogleApiAvailability.java b/play-services-base/src/main/java/com/google/android/gms/common/GoogleApiAvailability.java index 889cc7f6..30afec09 100644 --- a/play-services-base/src/main/java/com/google/android/gms/common/GoogleApiAvailability.java +++ b/play-services-base/src/main/java/com/google/android/gms/common/GoogleApiAvailability.java @@ -163,6 +163,19 @@ public class GoogleApiAvailability { return SUCCESS; } + /** + * Verifies that Google Play services is installed and enabled on this device, and that the version installed on + * this device is no older than the one required by this client or the version is not older than the one specified + * in minApkVersion. + * + * @return status code indicating whether there was an error. Can be one of following in + * {@link ConnectionResult}: SUCCESS, SERVICE_MISSING, SERVICE_UPDATING, + * SERVICE_VERSION_UPDATE_REQUIRED, SERVICE_DISABLED, SERVICE_INVALID + */ + public int isGooglePlayServicesAvailable(Context context, int minApkVersion) { + return isGooglePlayServicesAvailable(context); + } + /** * Determines whether an error can be resolved via user action. If true, proceed by calling * {@link #getErrorDialog(Activity, int, int)} and showing the dialog. diff --git a/play-services-basement/build.gradle b/play-services-basement/build.gradle index 4f2f05c5..bc627a1b 100644 --- a/play-services-basement/build.gradle +++ b/play-services-basement/build.gradle @@ -16,7 +16,6 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' dependencies { api "org.microg:safe-parcel:1.7.0" @@ -41,6 +40,10 @@ android { buildConfigField "int", "VERSION_CODE", "$appVersionCode" } + buildFeatures { + viewBinding = true + } + sourceSets { main.java.srcDirs += 'src/main/kotlin' } diff --git a/play-services-core/build.gradle b/play-services-core/build.gradle index 2a878698..7f3739f6 100644 --- a/play-services-core/build.gradle +++ b/play-services-core/build.gradle @@ -17,7 +17,6 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' -apply plugin: 'kotlin-android-extensions' dependencies { implementation 'com.squareup.wire:wire-runtime:3.6.1' @@ -70,6 +69,7 @@ android { buildFeatures { dataBinding = true + viewBinding = true } sourceSets { diff --git a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java index 56c273b9..dd32c1e1 100755 --- a/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java +++ b/play-services-core/src/main/java/org/microg/gms/checkin/CheckinService.java @@ -95,7 +95,9 @@ public class CheckinService extends IntentService { } catch (Exception e) { Log.w(TAG, e); } finally { - WakefulBroadcastReceiver.completeWakefulIntent(intent); + if (intent != null) { + WakefulBroadcastReceiver.completeWakefulIntent(intent); + } schedule(this); stopSelf(); } diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java b/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java index bc524047..ce32d8d3 100644 --- a/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java +++ b/play-services-core/src/main/java/org/microg/gms/gcm/GcmDatabase.java @@ -1,17 +1,6 @@ /* - * Copyright (C) 2013-2017 microG Project Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-FileCopyrightText: 2016, microG Project Team + * SPDX-License-Identifier: Apache-2.0 */ package org.microg.gms.gcm; @@ -81,13 +70,13 @@ public class GcmDatabase extends SQLiteOpenHelper { public final boolean wakeForDelivery; private App(Cursor cursor) { - packageName = cursor.getString(cursor.getColumnIndex(FIELD_PACKAGE_NAME)); - lastError = cursor.getString(cursor.getColumnIndex(FIELD_LAST_ERROR)); - lastMessageTimestamp = cursor.getLong(cursor.getColumnIndex(FIELD_LAST_MESSAGE_TIMESTAMP)); - totalMessageCount = cursor.getLong(cursor.getColumnIndex(FIELD_TOTAL_MESSAGE_COUNT)); - totalMessageBytes = cursor.getLong(cursor.getColumnIndex(FIELD_TOTAL_MESSAGE_BYTES)); - allowRegister = cursor.getLong(cursor.getColumnIndex(FIELD_ALLOW_REGISTER)) == 1; - wakeForDelivery = cursor.getLong(cursor.getColumnIndex(FIELD_WAKE_FOR_DELIVERY)) == 1; + packageName = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_PACKAGE_NAME)); + lastError = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_LAST_ERROR)); + lastMessageTimestamp = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_LAST_MESSAGE_TIMESTAMP)); + totalMessageCount = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_TOTAL_MESSAGE_COUNT)); + totalMessageBytes = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_TOTAL_MESSAGE_BYTES)); + allowRegister = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_ALLOW_REGISTER)) == 1; + wakeForDelivery = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_WAKE_FOR_DELIVERY)) == 1; } public boolean hasError() { @@ -102,10 +91,10 @@ public class GcmDatabase extends SQLiteOpenHelper { public final String registerId; public Registration(Cursor cursor) { - packageName = cursor.getString(cursor.getColumnIndex(FIELD_PACKAGE_NAME)); - signature = cursor.getString(cursor.getColumnIndex(FIELD_SIGNATURE)); - timestamp = cursor.getLong(cursor.getColumnIndex(FIELD_TIMESTAMP)); - registerId = cursor.getString(cursor.getColumnIndex(FIELD_REGISTER_ID)); + packageName = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_PACKAGE_NAME)); + signature = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_SIGNATURE)); + timestamp = cursor.getLong(cursor.getColumnIndexOrThrow(FIELD_TIMESTAMP)); + registerId = cursor.getString(cursor.getColumnIndexOrThrow(FIELD_REGISTER_ID)); } } diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java index cdf5b3ca..8b3d45d7 100644 --- a/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java +++ b/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java @@ -320,7 +320,7 @@ public class McsService extends Service implements Handler.Callback { WakefulBroadcastReceiver.completeWakefulIntent(intent); } else if (connectIntent == null) { connectIntent = intent; - } else { + } else if (intent != null) { WakefulBroadcastReceiver.completeWakefulIntent(intent); } } diff --git a/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java b/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java index c7ed2c0e..c50f2b09 100644 --- a/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java +++ b/play-services-core/src/main/java/org/microg/gms/people/PeopleManager.java @@ -42,13 +42,13 @@ public class PeopleManager { public static final String USERINFO_URL = "https://www.googleapis.com/oauth2/v1/userinfo"; public static final String REGEX_SEARCH_USER_PHOTO = "https?\\:\\/\\/lh([0-9]*)\\.googleusercontent\\.com/"; - public static File getOwnerAvaterFile(Context context, String accountName, boolean network) { + public static File getOwnerAvatarFile(Context context, String accountName, boolean network) { DatabaseHelper databaseHelper = new DatabaseHelper(context); Cursor cursor = databaseHelper.getOwner(accountName); String url = null; if (cursor.moveToNext()) { int idx = cursor.getColumnIndex("avatar"); - if (!cursor.isNull(idx)) url = cursor.getString(idx); + if (idx >= 0 && !cursor.isNull(idx)) url = cursor.getString(idx); } cursor.close(); databaseHelper.close(); @@ -75,7 +75,7 @@ public class PeopleManager { } public static Bitmap getOwnerAvatarBitmap(Context context, String accountName, boolean network) { - File avaterFile = getOwnerAvaterFile(context, accountName, network); + File avaterFile = getOwnerAvatarFile(context, accountName, network); if (avaterFile == null) return null; return BitmapFactory.decodeFile(avaterFile.getPath()); } diff --git a/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java b/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java index dbccb1c8..8f0a88d3 100644 --- a/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java +++ b/play-services-core/src/main/java/org/microg/gms/people/PeopleServiceImpl.java @@ -121,7 +121,7 @@ public class PeopleServiceImpl extends IPeopleService.Stub { extras.putBoolean("rewindable", false); extras.putInt("width", 0); extras.putInt("height", 0); - File avaterFile = PeopleManager.getOwnerAvaterFile(context, account, true); + File avaterFile = PeopleManager.getOwnerAvatarFile(context, account, true); try { ParcelFileDescriptor fileDescriptor = null; if (avaterFile != null) { diff --git a/play-services-core/src/main/java/org/microg/gms/ui/AskPushPermission.java b/play-services-core/src/main/java/org/microg/gms/ui/AskPushPermission.java deleted file mode 100755 index 8fdef45f..00000000 --- a/play-services-core/src/main/java/org/microg/gms/ui/AskPushPermission.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.microg.gms.ui; - -import android.app.Activity; -import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.os.Bundle; -import android.os.ResultReceiver; -import android.text.Html; -import android.widget.TextView; - -import androidx.fragment.app.FragmentActivity; - -import com.mgoogle.android.gms.R; - -import org.microg.gms.gcm.GcmDatabase; -import org.microg.gms.gcm.PushRegisterService; - -import static org.microg.gms.gcm.GcmConstants.EXTRA_APP; -import static org.microg.gms.gcm.GcmConstants.EXTRA_KID; -import static org.microg.gms.gcm.GcmConstants.EXTRA_PENDING_INTENT; - -public class AskPushPermission extends FragmentActivity { - public static final String EXTRA_REQUESTED_PACKAGE = "package"; - public static final String EXTRA_RESULT_RECEIVER = "receiver"; - public static final String EXTRA_EXPLICIT = "explicit"; - - private GcmDatabase database; - - private String packageName; - private ResultReceiver resultReceiver; - private boolean answered; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - database = new GcmDatabase(this); - - packageName = getIntent().getStringExtra(EXTRA_REQUESTED_PACKAGE); - resultReceiver = getIntent().getParcelableExtra(EXTRA_RESULT_RECEIVER); - if (packageName == null || resultReceiver == null) { - answered = true; - finish(); - return; - } - - if (database.getApp(packageName) != null) { - resultReceiver.send(Activity.RESULT_OK, Bundle.EMPTY); - answered = true; - finish(); - return; - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (!answered) { - resultReceiver.send(Activity.RESULT_CANCELED, Bundle.EMPTY); - } - database.close(); - } -} diff --git a/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt b/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt index 1b0e0c94..00d0721e 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/gcm/PushRegisterService.kt @@ -24,7 +24,6 @@ import org.microg.gms.common.ForegroundServiceContext import org.microg.gms.common.PackageUtils import org.microg.gms.common.Utils import org.microg.gms.gcm.GcmConstants.* -import org.microg.gms.ui.AskPushPermission import java.util.concurrent.atomic.AtomicBoolean import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine @@ -97,11 +96,12 @@ class PushRegisterService : LifecycleService() { } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - WakefulBroadcastReceiver.completeWakefulIntent(intent) - Log.d(TAG, "onStartCommand: $intent") - lifecycleScope.launchWhenStarted { - if (intent == null) return@launchWhenStarted - handleIntent(intent) + if (intent != null) { + WakefulBroadcastReceiver.completeWakefulIntent(intent) + Log.d(TAG, "onStartCommand: $intent") + lifecycleScope.launchWhenStarted { + handleIntent(intent) + } } return super.onStartCommand(intent, flags, startId) }