@iternio/react-native-auto-play 0.3.2 → 0.3.4
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 +7 -16
- package/android/src/auto/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidTelemetryObserver.kt +1 -1
- package/android/src/automotive/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidTelemetryObserver.kt +1 -1
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidAutoService.kt +7 -4
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/AndroidAutoTelemetryHolder.kt +11 -7
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/ReactContextResolver.kt +17 -41
- package/lib/types/Telemetry.d.ts +1 -0
- package/nitrogen/generated/android/c++/JVehicleTelemetryItem.hpp +7 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VehicleTelemetryItem.kt +6 -3
- package/nitrogen/generated/shared/c++/VehicleTelemetryItem.hpp +6 -2
- package/package.json +1 -1
- package/src/types/Telemetry.ts +1 -0
package/android/build.gradle
CHANGED
|
@@ -5,7 +5,7 @@ buildscript {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
dependencies {
|
|
8
|
-
classpath "com.android.tools.build:gradle:8.13.
|
|
8
|
+
classpath "com.android.tools.build:gradle:8.13.2"
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -14,18 +14,11 @@ def reactNativeArchitectures() {
|
|
|
14
14
|
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
def isNewArchitectureEnabled() {
|
|
18
|
-
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
-
}
|
|
20
|
-
|
|
21
17
|
apply plugin: "com.android.library"
|
|
22
18
|
apply plugin: 'org.jetbrains.kotlin.android'
|
|
23
19
|
apply from: '../nitrogen/generated/android/ReactNativeAutoPlay+autolinking.gradle'
|
|
24
20
|
apply from: "./fix-prefab.gradle"
|
|
25
|
-
|
|
26
|
-
if (isNewArchitectureEnabled()) {
|
|
27
|
-
apply plugin: "com.facebook.react"
|
|
28
|
-
}
|
|
21
|
+
apply plugin: "com.facebook.react"
|
|
29
22
|
|
|
30
23
|
def getExtOrDefault(name) {
|
|
31
24
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ReactNativeAutoPlay_" + name]
|
|
@@ -117,12 +110,10 @@ android {
|
|
|
117
110
|
|
|
118
111
|
sourceSets {
|
|
119
112
|
main {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
]
|
|
125
|
-
}
|
|
113
|
+
java.srcDirs += [
|
|
114
|
+
// React Codegen files
|
|
115
|
+
"${project.buildDir}/generated/source/codegen/java"
|
|
116
|
+
]
|
|
126
117
|
|
|
127
118
|
if (getExtOrDefault("isAutomotiveApp") == "true") {
|
|
128
119
|
java.srcDirs += 'src/automotive/java'
|
|
@@ -163,6 +154,6 @@ dependencies {
|
|
|
163
154
|
}
|
|
164
155
|
|
|
165
156
|
implementation 'com.google.android.gms:play-services-base:18.10.0'
|
|
166
|
-
implementation 'com.google.android.gms:play-services-auth:21.5.
|
|
157
|
+
implementation 'com.google.android.gms:play-services-auth:21.5.1'
|
|
167
158
|
}
|
|
168
159
|
|
|
@@ -27,7 +27,7 @@ object AndroidTelemetryObserver : TelemetryObserver() {
|
|
|
27
27
|
model.year.value
|
|
28
28
|
} else null
|
|
29
29
|
|
|
30
|
-
telemetryHolder.updateVehicle(name, manufacturer, year)
|
|
30
|
+
telemetryHolder.updateVehicle(name, manufacturer, year, null)
|
|
31
31
|
|
|
32
32
|
telemetryHolder.toTelemetry()?.let {
|
|
33
33
|
telemetryCallbacks.forEach { callback ->
|
|
@@ -45,7 +45,7 @@ object AndroidTelemetryObserver : TelemetryObserver() {
|
|
|
45
45
|
VehiclePropertyIds.INFO_EV_BATTERY_CAPACITY, VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL
|
|
46
46
|
)?.value ?: 0f
|
|
47
47
|
|
|
48
|
-
telemetryHolder.updateVehicle(carModel, carManufacturer, carModelYear)
|
|
48
|
+
telemetryHolder.updateVehicle(carModel, carManufacturer, carModelYear, batteryCapacity)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
val vehiclePropertyReceiver = object : CarPropertyManager.CarPropertyEventCallback {
|
|
@@ -11,6 +11,7 @@ import android.content.ServiceConnection
|
|
|
11
11
|
import android.content.pm.ApplicationInfo
|
|
12
12
|
import android.content.pm.PackageManager
|
|
13
13
|
import android.graphics.Bitmap
|
|
14
|
+
import android.os.Build
|
|
14
15
|
import android.os.IBinder
|
|
15
16
|
import android.util.Log
|
|
16
17
|
import androidx.car.app.CarAppService
|
|
@@ -61,11 +62,13 @@ class AndroidAutoService : CarAppService() {
|
|
|
61
62
|
notificationManager = getSystemService(NotificationManager::class.java)
|
|
62
63
|
val appLabel = AppInfo.getApplicationLabel(this)
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
66
|
+
getSystemService(NotificationManager::class.java).createNotificationChannel(
|
|
67
|
+
NotificationChannel(
|
|
68
|
+
CHANNEL_ID, appLabel, NotificationManager.IMPORTANCE_DEFAULT
|
|
69
|
+
)
|
|
67
70
|
)
|
|
68
|
-
|
|
71
|
+
}
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
override fun onCreateSession(sessionInfo: SessionInfo): Session {
|
|
@@ -42,14 +42,17 @@ class AndroidAutoTelemetryHolder {
|
|
|
42
42
|
private var name: String? = null
|
|
43
43
|
private var manufacturer: String? = null
|
|
44
44
|
private var year: Int? = null
|
|
45
|
+
private var batteryCapacity: Float? = null
|
|
45
46
|
|
|
46
|
-
fun updateVehicle(name: String?, manufacturer: String?, year: Int?) =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
fun updateVehicle(name: String?, manufacturer: String?, year: Int?, batteryCapacity: Float?) =
|
|
48
|
+
synchronized(lock) {
|
|
49
|
+
this.name = name
|
|
50
|
+
this.manufacturer = manufacturer
|
|
51
|
+
this.year = year
|
|
52
|
+
this.batteryCapacity = batteryCapacity
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
isDirty = true
|
|
55
|
+
}
|
|
53
56
|
|
|
54
57
|
fun updateBatteryLevel(value: Float) = synchronized(lock) {
|
|
55
58
|
if (batteryLevel == value) {
|
|
@@ -208,7 +211,8 @@ class AndroidAutoTelemetryHolder {
|
|
|
208
211
|
vehicle = VehicleTelemetryItem(
|
|
209
212
|
name = createStringTelemetryItem(name),
|
|
210
213
|
manufacturer = createStringTelemetryItem(manufacturer),
|
|
211
|
-
year = createNumericTelemetryItem(year?.toFloat(), 0)
|
|
214
|
+
year = createNumericTelemetryItem(year?.toFloat(), 0),
|
|
215
|
+
batteryCapacity = createNumericTelemetryItem(batteryCapacity, 0)
|
|
212
216
|
)
|
|
213
217
|
)
|
|
214
218
|
}
|
|
@@ -2,59 +2,35 @@ package com.margelo.nitro.swe.iternio.reactnativeautoplay.utils
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.ReactApplication
|
|
4
4
|
import com.facebook.react.ReactInstanceEventListener
|
|
5
|
-
import com.facebook.react.ReactInstanceManager
|
|
6
5
|
import com.facebook.react.bridge.ReactContext
|
|
7
|
-
import com.margelo.nitro.BuildConfig
|
|
8
6
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
9
7
|
import kotlin.coroutines.resume
|
|
10
8
|
|
|
11
9
|
object ReactContextResolver {
|
|
12
10
|
suspend fun getReactContext(application: ReactApplication): ReactContext {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
application.reactHost ?: throw IllegalArgumentException("application host null")
|
|
16
|
-
return suspendCancellableCoroutine { continuation ->
|
|
17
|
-
host.currentReactContext?.let {
|
|
18
|
-
continuation.resume(it)
|
|
19
|
-
return@suspendCancellableCoroutine
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
val listener = object : ReactInstanceEventListener {
|
|
23
|
-
override fun onReactContextInitialized(context: ReactContext) {
|
|
24
|
-
host.removeReactInstanceEventListener(this)
|
|
25
|
-
continuation.resume(context)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
host.addReactInstanceEventListener(listener)
|
|
11
|
+
val host =
|
|
12
|
+
application.reactHost ?: throw IllegalArgumentException("application host null")
|
|
29
13
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
host.start()
|
|
14
|
+
return suspendCancellableCoroutine { continuation ->
|
|
15
|
+
host.currentReactContext?.let {
|
|
16
|
+
continuation.resume(it)
|
|
17
|
+
return@suspendCancellableCoroutine
|
|
35
18
|
}
|
|
36
|
-
} else {
|
|
37
|
-
val reactInstanceManager = application.reactNativeHost.reactInstanceManager
|
|
38
|
-
return suspendCancellableCoroutine { continuation ->
|
|
39
|
-
reactInstanceManager.currentReactContext?.let {
|
|
40
|
-
continuation.resume(it)
|
|
41
|
-
return@suspendCancellableCoroutine
|
|
42
|
-
}
|
|
43
19
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
reactInstanceManager.addReactInstanceEventListener(listener)
|
|
51
|
-
|
|
52
|
-
continuation.invokeOnCancellation {
|
|
53
|
-
reactInstanceManager.removeReactInstanceEventListener(listener)
|
|
20
|
+
val listener = object : ReactInstanceEventListener {
|
|
21
|
+
override fun onReactContextInitialized(context: ReactContext) {
|
|
22
|
+
host.removeReactInstanceEventListener(this)
|
|
23
|
+
continuation.resume(context)
|
|
54
24
|
}
|
|
25
|
+
}
|
|
26
|
+
host.addReactInstanceEventListener(listener)
|
|
55
27
|
|
|
56
|
-
|
|
28
|
+
continuation.invokeOnCancellation {
|
|
29
|
+
host.removeReactInstanceEventListener(listener)
|
|
57
30
|
}
|
|
31
|
+
|
|
32
|
+
host.start()
|
|
58
33
|
}
|
|
34
|
+
|
|
59
35
|
}
|
|
60
36
|
}
|
package/lib/types/Telemetry.d.ts
CHANGED
|
@@ -42,10 +42,13 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
42
42
|
jni::local_ref<JNumericTelemetryItem> year = this->getFieldValue(fieldYear);
|
|
43
43
|
static const auto fieldManufacturer = clazz->getField<JStringTelemetryItem>("manufacturer");
|
|
44
44
|
jni::local_ref<JStringTelemetryItem> manufacturer = this->getFieldValue(fieldManufacturer);
|
|
45
|
+
static const auto fieldBatteryCapacity = clazz->getField<JNumericTelemetryItem>("batteryCapacity");
|
|
46
|
+
jni::local_ref<JNumericTelemetryItem> batteryCapacity = this->getFieldValue(fieldBatteryCapacity);
|
|
45
47
|
return VehicleTelemetryItem(
|
|
46
48
|
name != nullptr ? std::make_optional(name->toCpp()) : std::nullopt,
|
|
47
49
|
year != nullptr ? std::make_optional(year->toCpp()) : std::nullopt,
|
|
48
|
-
manufacturer != nullptr ? std::make_optional(manufacturer->toCpp()) : std::nullopt
|
|
50
|
+
manufacturer != nullptr ? std::make_optional(manufacturer->toCpp()) : std::nullopt,
|
|
51
|
+
batteryCapacity != nullptr ? std::make_optional(batteryCapacity->toCpp()) : std::nullopt
|
|
49
52
|
);
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -55,14 +58,15 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
55
58
|
*/
|
|
56
59
|
[[maybe_unused]]
|
|
57
60
|
static jni::local_ref<JVehicleTelemetryItem::javaobject> fromCpp(const VehicleTelemetryItem& value) {
|
|
58
|
-
using JSignature = JVehicleTelemetryItem(jni::alias_ref<JStringTelemetryItem>, jni::alias_ref<JNumericTelemetryItem>, jni::alias_ref<JStringTelemetryItem>);
|
|
61
|
+
using JSignature = JVehicleTelemetryItem(jni::alias_ref<JStringTelemetryItem>, jni::alias_ref<JNumericTelemetryItem>, jni::alias_ref<JStringTelemetryItem>, jni::alias_ref<JNumericTelemetryItem>);
|
|
59
62
|
static const auto clazz = javaClassStatic();
|
|
60
63
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
61
64
|
return create(
|
|
62
65
|
clazz,
|
|
63
66
|
value.name.has_value() ? JStringTelemetryItem::fromCpp(value.name.value()) : nullptr,
|
|
64
67
|
value.year.has_value() ? JNumericTelemetryItem::fromCpp(value.year.value()) : nullptr,
|
|
65
|
-
value.manufacturer.has_value() ? JStringTelemetryItem::fromCpp(value.manufacturer.value()) : nullptr
|
|
68
|
+
value.manufacturer.has_value() ? JStringTelemetryItem::fromCpp(value.manufacturer.value()) : nullptr,
|
|
69
|
+
value.batteryCapacity.has_value() ? JNumericTelemetryItem::fromCpp(value.batteryCapacity.value()) : nullptr
|
|
66
70
|
);
|
|
67
71
|
}
|
|
68
72
|
};
|
|
@@ -25,7 +25,10 @@ data class VehicleTelemetryItem(
|
|
|
25
25
|
val year: NumericTelemetryItem?,
|
|
26
26
|
@DoNotStrip
|
|
27
27
|
@Keep
|
|
28
|
-
val manufacturer: StringTelemetryItem
|
|
28
|
+
val manufacturer: StringTelemetryItem?,
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
val batteryCapacity: NumericTelemetryItem?
|
|
29
32
|
) {
|
|
30
33
|
/* primary constructor */
|
|
31
34
|
|
|
@@ -37,8 +40,8 @@ data class VehicleTelemetryItem(
|
|
|
37
40
|
@Keep
|
|
38
41
|
@Suppress("unused")
|
|
39
42
|
@JvmStatic
|
|
40
|
-
private fun fromCpp(name: StringTelemetryItem?, year: NumericTelemetryItem?, manufacturer: StringTelemetryItem?): VehicleTelemetryItem {
|
|
41
|
-
return VehicleTelemetryItem(name, year, manufacturer)
|
|
43
|
+
private fun fromCpp(name: StringTelemetryItem?, year: NumericTelemetryItem?, manufacturer: StringTelemetryItem?, batteryCapacity: NumericTelemetryItem?): VehicleTelemetryItem {
|
|
44
|
+
return VehicleTelemetryItem(name, year, manufacturer, batteryCapacity)
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
}
|
|
@@ -47,10 +47,11 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
|
47
47
|
std::optional<StringTelemetryItem> name SWIFT_PRIVATE;
|
|
48
48
|
std::optional<NumericTelemetryItem> year SWIFT_PRIVATE;
|
|
49
49
|
std::optional<StringTelemetryItem> manufacturer SWIFT_PRIVATE;
|
|
50
|
+
std::optional<NumericTelemetryItem> batteryCapacity SWIFT_PRIVATE;
|
|
50
51
|
|
|
51
52
|
public:
|
|
52
53
|
VehicleTelemetryItem() = default;
|
|
53
|
-
explicit VehicleTelemetryItem(std::optional<StringTelemetryItem> name, std::optional<NumericTelemetryItem> year, std::optional<StringTelemetryItem> manufacturer): name(name), year(year), manufacturer(manufacturer) {}
|
|
54
|
+
explicit VehicleTelemetryItem(std::optional<StringTelemetryItem> name, std::optional<NumericTelemetryItem> year, std::optional<StringTelemetryItem> manufacturer, std::optional<NumericTelemetryItem> batteryCapacity): name(name), year(year), manufacturer(manufacturer), batteryCapacity(batteryCapacity) {}
|
|
54
55
|
|
|
55
56
|
public:
|
|
56
57
|
friend bool operator==(const VehicleTelemetryItem& lhs, const VehicleTelemetryItem& rhs) = default;
|
|
@@ -68,7 +69,8 @@ namespace margelo::nitro {
|
|
|
68
69
|
return margelo::nitro::swe::iternio::reactnativeautoplay::VehicleTelemetryItem(
|
|
69
70
|
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::StringTelemetryItem>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
|
|
70
71
|
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::NumericTelemetryItem>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "year"))),
|
|
71
|
-
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::StringTelemetryItem>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "manufacturer")))
|
|
72
|
+
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::StringTelemetryItem>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "manufacturer"))),
|
|
73
|
+
JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::NumericTelemetryItem>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "batteryCapacity")))
|
|
72
74
|
);
|
|
73
75
|
}
|
|
74
76
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::VehicleTelemetryItem& arg) {
|
|
@@ -76,6 +78,7 @@ namespace margelo::nitro {
|
|
|
76
78
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::StringTelemetryItem>>::toJSI(runtime, arg.name));
|
|
77
79
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "year"), JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::NumericTelemetryItem>>::toJSI(runtime, arg.year));
|
|
78
80
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "manufacturer"), JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::StringTelemetryItem>>::toJSI(runtime, arg.manufacturer));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "batteryCapacity"), JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::NumericTelemetryItem>>::toJSI(runtime, arg.batteryCapacity));
|
|
79
82
|
return obj;
|
|
80
83
|
}
|
|
81
84
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -89,6 +92,7 @@ namespace margelo::nitro {
|
|
|
89
92
|
if (!JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::StringTelemetryItem>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
|
|
90
93
|
if (!JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::NumericTelemetryItem>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "year")))) return false;
|
|
91
94
|
if (!JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::StringTelemetryItem>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "manufacturer")))) return false;
|
|
95
|
+
if (!JSIConverter<std::optional<margelo::nitro::swe::iternio::reactnativeautoplay::NumericTelemetryItem>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "batteryCapacity")))) return false;
|
|
92
96
|
return true;
|
|
93
97
|
}
|
|
94
98
|
};
|
package/package.json
CHANGED