From cffa41da95945da0e41bc14b8c8a4918a0301891 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sat, 17 Sep 2022 10:17:51 +0200 Subject: [PATCH] Disable firebase appdistribution We don't want to use it. And we do not want the REQUEST_INSTALL_PACKAGES permission from that. Change-Id: I82aeab98116bebeface33667e604300df0a71fa7 --- dependencies.gradle | 4 +- vector/build.gradle | 4 +- .../java/im/vector/app/di/FlavorModule.kt | 14 +++- .../app/nightly/FirebaseNightlyProxy.kt | 79 ------------------- 4 files changed, 15 insertions(+), 86 deletions(-) delete mode 100644 vector/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt diff --git a/dependencies.gradle b/dependencies.gradle index 77c601d7b6..8c52416846 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -84,8 +84,8 @@ ext.libs = [ ], google : [ 'material' : "com.google.android.material:material:1.6.1", - 'appdistributionApi' : "com.google.firebase:firebase-appdistribution-api-ktx:$appDistribution", - 'appdistribution' : "com.google.firebase:firebase-appdistribution:$appDistribution", + //'appdistributionApi' : "com.google.firebase:firebase-appdistribution-api-ktx:$appDistribution", + //'appdistribution' : "com.google.firebase:firebase-appdistribution:$appDistribution", // Phone number https://github.com/google/libphonenumber 'phonenumber' : "com.googlecode.libphonenumber:libphonenumber:8.12.54" ], diff --git a/vector/build.gradle b/vector/build.gradle index 313d2b1520..3093bc1f6c 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -187,9 +187,9 @@ dependencies { // Nightly // API-only library - gplayImplementation libs.google.appdistributionApi + //gplayImplementation libs.google.appdistributionApi // Full SDK implementation - gplayImplementation libs.google.appdistribution + //gplayImplementation libs.google.appdistribution // Work api libs.androidx.work diff --git a/vector/src/gplay/java/im/vector/app/di/FlavorModule.kt b/vector/src/gplay/java/im/vector/app/di/FlavorModule.kt index 2fe72313ea..08c72eb3c4 100644 --- a/vector/src/gplay/java/im/vector/app/di/FlavorModule.kt +++ b/vector/src/gplay/java/im/vector/app/di/FlavorModule.kt @@ -26,7 +26,7 @@ import im.vector.app.core.pushers.FcmHelper import im.vector.app.core.services.GuardServiceStarter import im.vector.app.features.home.NightlyProxy import im.vector.app.features.settings.legals.FlavorLegals -import im.vector.app.nightly.FirebaseNightlyProxy +//import im.vector.app.nightly.FirebaseNightlyProxy import im.vector.app.push.fcm.GoogleFcmHelper @InstallIn(SingletonComponent::class) @@ -38,10 +38,18 @@ abstract class FlavorModule { fun provideGuardServiceStarter(): GuardServiceStarter { return object : GuardServiceStarter {} } + + // SC: Copied from fdroid FlavorModule + @Provides + fun provideNightlyProxy() = object : NightlyProxy { + override fun onHomeResumed() { + // no op + } + } } - @Binds - abstract fun bindsNightlyProxy(nightlyProxy: FirebaseNightlyProxy): NightlyProxy + //@Binds + //abstract fun bindsNightlyProxy(nightlyProxy: FirebaseNightlyProxy): NightlyProxy @Binds abstract fun bindsFcmHelper(fcmHelper: GoogleFcmHelper): FcmHelper diff --git a/vector/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt b/vector/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt deleted file mode 100644 index 94a36036b6..0000000000 --- a/vector/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2022 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package im.vector.app.nightly - -import android.content.SharedPreferences -import androidx.core.content.edit -import com.google.firebase.appdistribution.FirebaseAppDistribution -import com.google.firebase.appdistribution.FirebaseAppDistributionException -import im.vector.app.core.di.DefaultPreferences -import im.vector.app.core.resources.BuildMeta -import im.vector.app.core.time.Clock -import im.vector.app.features.home.NightlyProxy -import timber.log.Timber -import javax.inject.Inject - -class FirebaseNightlyProxy @Inject constructor( - private val clock: Clock, - @DefaultPreferences - private val sharedPreferences: SharedPreferences, - private val buildMeta: BuildMeta, -) : NightlyProxy { - - override fun onHomeResumed() { - if (!canDisplayPopup()) return - val firebaseAppDistribution = FirebaseAppDistribution.getInstance() - firebaseAppDistribution.updateIfNewReleaseAvailable() - .addOnProgressListener { up -> - Timber.d("FirebaseAppDistribution progress: ${up.updateStatus}. ${up.apkBytesDownloaded}/${up.apkFileTotalBytes}") - } - .addOnFailureListener { e -> - if (e is FirebaseAppDistributionException) { - when (e.errorCode) { - FirebaseAppDistributionException.Status.NOT_IMPLEMENTED -> { - // SDK did nothing. This is expected when building for Play. - } - else -> { - // Handle other errors. - Timber.e(e, "FirebaseAppDistribution error, status: ${e.errorCode}") - } - } - } else { - Timber.e(e, "FirebaseAppDistribution - other error") - } - } - } - - private fun canDisplayPopup(): Boolean { - if (buildMeta.applicationId != "im.vector.app.nightly") return false - val today = clock.epochMillis() / A_DAY_IN_MILLIS - val lastDisplayPopupDay = sharedPreferences.getLong(SHARED_PREF_KEY, 0) - return (today > lastDisplayPopupDay) - .also { canDisplayPopup -> - if (canDisplayPopup) { - sharedPreferences.edit { - putLong(SHARED_PREF_KEY, today) - } - } - } - } - - companion object { - private const val A_DAY_IN_MILLIS = 8_600_000L - private const val SHARED_PREF_KEY = "LAST_NIGHTLY_POPUP_DAY" - } -}