1
0

Set buildTimestamp through manifest meta (#1556)

This commit is contained in:
Mikołaj Pich
2021-10-03 14:13:42 +02:00
committed by GitHub
parent 8e607d48f7
commit 60501fcd72
6 changed files with 36 additions and 19 deletions

View File

@ -106,7 +106,8 @@
</service>
<service
android:name=".services.messaging.AppMessagingService"
android:exported="false">
android:exported="false"
tools:ignore="MissingClass">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
@ -152,6 +153,10 @@
android:resource="@xml/provider_paths" />
</provider>
<meta-data
android:name="buildTimestamp"
android:value="${buildTimestamp}" />
<meta-data
android:name="install_channel"
android:value="${install_channel}" />
@ -162,7 +167,8 @@
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="${applicationId}.firebaseinitprovider"
android:enabled="${firebase_enabled}"
android:exported="false" />
android:exported="false"
tools:ignore="MissingClass" />
<meta-data
android:name="firebase_analytics_collection_enabled"

View File

@ -1,10 +1,12 @@
package io.github.wulkanowy.utils
import android.content.Context
import android.content.pm.PackageManager
import android.content.res.Resources
import android.os.Build.MANUFACTURER
import android.os.Build.MODEL
import android.os.Build.VERSION.SDK_INT
import io.github.wulkanowy.BuildConfig.BUILD_TIMESTAMP
import dagger.hilt.android.qualifiers.ApplicationContext
import io.github.wulkanowy.BuildConfig.DEBUG
import io.github.wulkanowy.BuildConfig.FLAVOR
import io.github.wulkanowy.BuildConfig.VERSION_CODE
@ -13,13 +15,21 @@ import javax.inject.Inject
import javax.inject.Singleton
@Singleton
open class AppInfo @Inject constructor() {
open class AppInfo @Inject constructor(
@ApplicationContext private val context: Context,
) {
open val isDebug get() = DEBUG
open val versionCode get() = VERSION_CODE
open val buildTimestamp get() = BUILD_TIMESTAMP
open val buildTimestamp: Long
get() {
val info = context.packageManager.getApplicationInfo(
context.packageName, PackageManager.GET_META_DATA,
)
return info.metaData?.getFloat("buildTimestamp")?.toLong() ?: 0
}
open val buildFlavor get() = FLAVOR