@rovq/react-native 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/build.gradle
CHANGED
|
@@ -6,8 +6,12 @@ plugins {
|
|
|
6
6
|
// seconds. Inside an app, the React Native integration is added on top of it.
|
|
7
7
|
def insideApp = rootProject.name != 'rovq-engine'
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
|
|
9
|
+
// Android Gradle Plugin 9 compiles Kotlin itself, unless an app turns that off, as React Native's
|
|
10
|
+
// template does. Earlier versions, used up to React Native 0.87, need the Kotlin plugin, or the
|
|
11
|
+
// Kotlin sources are left out and the app cannot find any of these classes.
|
|
12
|
+
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
|
|
13
|
+
def usesKotlinPlugin = insideApp &&
|
|
14
|
+
(agpMajor < 9 || findProperty('android.builtInKotlin') == 'false')
|
|
11
15
|
|
|
12
16
|
// Rebuilding only changed files fails with "Cannot access ... it is internal" when this package is
|
|
13
17
|
// linked through a symbolic link, as npm's file: dependencies are. Compiling it fully each time
|
|
@@ -5,10 +5,13 @@ import android.app.Application
|
|
|
5
5
|
import android.content.pm.PackageInfo
|
|
6
6
|
import android.os.Build
|
|
7
7
|
import android.os.Bundle
|
|
8
|
+
import android.util.Log
|
|
8
9
|
import com.rovq.engine.EngineConfig
|
|
9
10
|
import com.rovq.engine.RovqEngine
|
|
10
11
|
import java.io.File
|
|
11
12
|
|
|
13
|
+
private const val LOG_TAG = "Rovq"
|
|
14
|
+
|
|
12
15
|
/** What an app supplies. Everything here ships inside the app, so nothing here is secret. */
|
|
13
16
|
data class RovqConfig(
|
|
14
17
|
val apiUrl: String,
|
|
@@ -33,23 +36,33 @@ object Rovq {
|
|
|
33
36
|
val engineOrNull: RovqEngine?
|
|
34
37
|
get() = instance
|
|
35
38
|
|
|
39
|
+
/**
|
|
40
|
+
* If the settings are unusable, such as a public key in the wrong format, the app still
|
|
41
|
+
* starts, on the bundle inside it, and accepts no update. A typo must not crash every user's
|
|
42
|
+
* app. The reason is logged under the tag Rovq. iOS behaves the same.
|
|
43
|
+
*/
|
|
36
44
|
@Synchronized
|
|
37
45
|
fun initialize(application: Application, config: RovqConfig) {
|
|
38
46
|
if (instance != null) return
|
|
39
|
-
val
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
val engine = try {
|
|
48
|
+
val info = application.packageManager.getPackageInfo(application.packageName, 0)
|
|
49
|
+
RovqEngine(
|
|
50
|
+
File(application.filesDir, "rovq"),
|
|
51
|
+
EngineConfig(
|
|
52
|
+
apiUrl = config.apiUrl,
|
|
53
|
+
deploymentKey = config.deploymentKey,
|
|
54
|
+
runtimeVersion = config.runtimeVersion,
|
|
55
|
+
binaryVersion = info.versionName ?: "0",
|
|
56
|
+
binaryId = binaryIdOf(info),
|
|
57
|
+
trustedKeys = config.trustedKeys,
|
|
58
|
+
allowInsecureUrls = config.allowInsecureUrls,
|
|
59
|
+
),
|
|
60
|
+
builtInFiles = ResourceFiles(application),
|
|
61
|
+
)
|
|
62
|
+
} catch (error: Exception) {
|
|
63
|
+
Log.e(LOG_TAG, "Could not start, so updates are off: ${error.message}", error)
|
|
64
|
+
return
|
|
65
|
+
}
|
|
53
66
|
instance = engine
|
|
54
67
|
application.registerActivityLifecycleCallbacks(BackgroundWatcher(engine))
|
|
55
68
|
watchForCrashes(engine)
|