π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix auto-source reporting
Neeraj Guptaaab46a6aeb34
diff --git a/mobile/apps/photos/android/app/src/playstore/kotlin/io/ente/photos/InstallSourceProvider.kt b/mobile/apps/photos/android/app/src/playstore/kotlin/io/ente/photos/InstallSourceProvider.ktindex 2c4d30a9c5..023902d1de 100644--- a/mobile/apps/photos/android/app/src/playstore/kotlin/io/ente/photos/InstallSourceProvider.kt+++ b/mobile/apps/photos/android/app/src/playstore/kotlin/io/ente/photos/InstallSourceProvider.kt@@ -1,6 +1,8 @@package io.ente.photosimport android.content.Context+import android.content.pm.PackageManager+import android.os.Buildimport android.os.Handlerimport android.os.Looperimport com.android.installreferrer.api.InstallReferrerClient@@ -44,6 +46,13 @@ class InstallSourceProvider(private val context: Context) {callback(source)return}+ if (!isFreshInstall()) {+ val emptySource = InstallSource(emptyMap())+ cachedSource = emptySource+ store.saveSource(emptySource)+ callback(emptySource)+ return+ }pendingCallbacks.add(callback)if (isFetching) {@@ -125,7 +134,26 @@ class InstallSourceProvider(private val context: Context) {}}+ private fun isFreshInstall(): Boolean {+ val packageInfo = try {+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {+ context.packageManager.getPackageInfo(+ context.packageName,+ PackageManager.PackageInfoFlags.of(0L),+ )+ } else {+ @Suppress("DEPRECATION")+ context.packageManager.getPackageInfo(context.packageName, 0)+ }+ } catch (_: Exception) {+ return false+ }+ val installUpdateDeltaMs = packageInfo.lastUpdateTime - packageInfo.firstInstallTime+ return installUpdateDeltaMs in 0L..FRESH_INSTALL_TOLERANCE_MS+ }+private companion object {const val INSTALL_REFERRER_TIMEOUT_MS = 2000L+ const val FRESH_INSTALL_TOLERANCE_MS = 2 * 60 * 1000L}}