forked from geode-sdk/android-launcher
add google play support (#82)
This commit is contained in:
1 parent
2016aa4e90
commit
0dba4f0606
4 files changed
+95
-9
No files matched your search
+16
-1
@@ -39,7 +39,7 @@ android {
|
||||
|
||||
splits {
|
||||
abi {
|
||||
isEnable = true
|
||||
isEnable = !project.hasProperty("disableAbiSplits")
|
||||
reset()
|
||||
|
||||
//noinspection ChromeOsAbiSupport. i'm sorry!
|
||||
@@ -49,6 +49,21 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions += "distribution"
|
||||
|
||||
productFlavors {
|
||||
create("standard") {
|
||||
dimension = "distribution"
|
||||
isDefault = true
|
||||
buildConfigField("boolean", "GOOGLE_PLAY_BUILD", "false")
|
||||
}
|
||||
|
||||
create("googlePlay") {
|
||||
dimension = "distribution"
|
||||
buildConfigField("boolean", "GOOGLE_PLAY_BUILD", "true")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.REQUEST_INSTALL_PACKAGES"
|
||||
tools:node="remove" />
|
||||
|
||||
</manifest>
|
||||
@@ -331,6 +331,11 @@ class ReleaseManager private constructor(
|
||||
}
|
||||
|
||||
private suspend fun getLatestLauncherUpdate(): DownloadableLauncherRelease? {
|
||||
if (BuildConfig.GOOGLE_PLAY_BUILD) {
|
||||
// don't check for updates on Google Play builds
|
||||
return null
|
||||
}
|
||||
|
||||
return try {
|
||||
releaseRepository.getLatestLauncherRelease()
|
||||
} catch (e: Exception) {
|
||||
@@ -340,6 +345,8 @@ class ReleaseManager private constructor(
|
||||
}
|
||||
|
||||
suspend fun checkLauncherUpdate() {
|
||||
if (BuildConfig.GOOGLE_PLAY_BUILD) return
|
||||
|
||||
val launcherRelease = getLatestLauncherUpdate() ?: return
|
||||
|
||||
// unconditionally track it, we're not using it for checks and it might be good to have
|
||||
@@ -356,6 +363,8 @@ class ReleaseManager private constructor(
|
||||
}
|
||||
|
||||
fun checkCachedLauncherUpdate() {
|
||||
if (BuildConfig.GOOGLE_PLAY_BUILD) return
|
||||
|
||||
val lastUpdate = PreferenceUtils.get(applicationContext)
|
||||
.getString(PreferenceUtils.Key.LAST_LAUNCHER_UPDATE) ?: return
|
||||
|
||||
@@ -365,6 +374,12 @@ class ReleaseManager private constructor(
|
||||
}
|
||||
|
||||
suspend fun downloadLatestLauncherUpdate(): Result<File> {
|
||||
if (BuildConfig.GOOGLE_PLAY_BUILD) {
|
||||
return Result.failure(UnsupportedOperationException(
|
||||
"Launcher updates are not supported on Google Play builds"
|
||||
))
|
||||
}
|
||||
|
||||
val update = _availableLauncherUpdateDetails.value
|
||||
?: getLatestLauncherUpdate()
|
||||
?: return Result.failure(FileNotFoundException())
|
||||
|
||||
Reference in new issue
Block a user