@iternio/react-native-auto-play 0.3.4 → 0.3.6

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.
@@ -9,6 +9,7 @@ import androidx.lifecycle.Lifecycle
9
9
  import androidx.lifecycle.LifecycleEventObserver
10
10
  import androidx.lifecycle.LifecycleOwner
11
11
  import com.facebook.react.bridge.UiThreadUtil
12
+ import java.util.concurrent.ConcurrentHashMap
12
13
  import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.AndroidAutoTemplate
13
14
  import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.GridTemplate
14
15
  import com.margelo.nitro.swe.iternio.reactnativeautoplay.template.InformationTemplate
@@ -117,15 +118,18 @@ class AndroidAutoScreen(
117
118
  companion object {
118
119
  const val TAG = "AndroidAutoScreen"
119
120
 
120
- private val screens = mutableMapOf<String, AndroidAutoScreen>()
121
+ private val screens = ConcurrentHashMap<String, AndroidAutoScreen>()
121
122
 
122
123
  fun getScreen(marker: String): AndroidAutoScreen? {
123
124
  return screens[marker]
124
125
  }
125
126
 
126
127
  fun getScreenManager(): ScreenManager? {
127
- return screens[AndroidAutoSession.ROOT_SESSION]?.screenManager
128
- }
128
+ val clusterSessions = AndroidAutoSession.getClusterSessions().toSet()
129
+ return screens.entries
130
+ .firstOrNull { !clusterSessions.contains(it.key) }
131
+ ?.value?.screenManager
132
+ }
129
133
 
130
134
  fun invalidateScreens() {
131
135
  for (screen in screens) {
@@ -143,4 +147,4 @@ class AndroidAutoScreen(
143
147
  }
144
148
  }
145
149
  }
146
- }
150
+ }
@@ -23,6 +23,8 @@ import kotlinx.coroutines.CoroutineScope
23
23
  import kotlinx.coroutines.Dispatchers
24
24
  import kotlinx.coroutines.launch
25
25
  import java.util.UUID
26
+ import java.util.concurrent.ConcurrentHashMap
27
+ import java.util.concurrent.CopyOnWriteArrayList
26
28
 
27
29
  class AndroidAutoSession(sessionInfo: SessionInfo, private val reactApplication: ReactApplication) :
28
30
  Session() {
@@ -246,9 +248,9 @@ class AndroidAutoSession(sessionInfo: SessionInfo, private val reactApplication:
246
248
  const val ROOT_SESSION = "AutoPlayRoot"
247
249
 
248
250
  private lateinit var reactContext: ReactContext
249
- private val sessions = mutableMapOf<String, ScreenContext>()
251
+ private val sessions = ConcurrentHashMap<String, ScreenContext>()
250
252
 
251
- private val clusterSessions = mutableListOf<String>()
253
+ private val clusterSessions = CopyOnWriteArrayList<String>()
252
254
 
253
255
  fun getIsConnected(): Boolean {
254
256
  return sessions.containsKey(ROOT_SESSION)
@@ -55,100 +55,60 @@ class AndroidAutoTelemetryHolder {
55
55
  }
56
56
 
57
57
  fun updateBatteryLevel(value: Float) = synchronized(lock) {
58
- if (batteryLevel == value) {
59
- return
60
- }
61
-
62
58
  batteryLevel = value
63
59
  batteryLevelTimestamp = (System.currentTimeMillis() / 1000L).toInt()
64
60
  isDirty = true
65
61
  }
66
62
 
67
63
  fun updateFuelLevel(value: Float) = synchronized(lock) {
68
- if (fuelLevel == value) {
69
- return
70
- }
71
-
72
64
  fuelLevel = value
73
65
  fuelLevelTimestamp = (System.currentTimeMillis() / 1000L).toInt()
74
66
  isDirty = true
75
67
  }
76
68
 
77
69
  fun updateRange(value: Float) = synchronized(lock) {
78
- if (range == value) {
79
- return
80
- }
81
-
82
70
  range = value
83
71
  rangeTimestamp = (System.currentTimeMillis() / 1000L).toInt()
84
72
  isDirty = true
85
73
  }
86
74
 
87
75
  fun updateSpeed(value: Float?) = synchronized(lock) {
88
- if (speed == value) {
89
- return
90
- }
91
-
92
76
  speed = value
93
77
  speedTimestamp = (System.currentTimeMillis() / 1000L).toInt()
94
78
  isDirty = true
95
79
  }
96
80
 
97
81
  fun updateOdometer(value: Float?) = synchronized(lock) {
98
- if (odometer == value) {
99
- return
100
- }
101
-
102
82
  odometer = value
103
83
  odometerTimestamp = (System.currentTimeMillis() / 1000L).toInt()
104
84
  isDirty = true
105
85
  }
106
86
 
107
87
  fun updateSelectedGear(value: Int?) = synchronized(lock) {
108
- if (value == selectedGear) {
109
- return
110
- }
111
-
112
88
  selectedGear = value
113
89
  selectedGearTimestamp = (System.currentTimeMillis() / 1000L).toInt()
114
90
  isDirty = true
115
91
  }
116
92
 
117
93
  fun updateEnvOutsideTemperature(value: Float?) = synchronized(lock) {
118
- if (value == envOutsideTemperature) {
119
- return
120
- }
121
-
122
94
  envOutsideTemperature = value
123
95
  envOutsideTemperatureTimestamp = (System.currentTimeMillis() / 1000L).toInt()
124
96
  isDirty = true
125
97
  }
126
98
 
127
99
  fun updateEvChargePortConnected(value: Boolean?) = synchronized(lock) {
128
- if (value == evChargePortConnected) {
129
- return
130
- }
131
-
132
100
  evChargePortConnected = value
133
101
  evChargePortConnectedTimestamp = (System.currentTimeMillis() / 1000L).toInt()
134
102
  isDirty = true
135
103
  }
136
104
 
137
105
  fun updateEvBatteryInstantaneousChargeRate(value: Float?) = synchronized(lock) {
138
- if (value == evBatteryInstantaneousChargeRate) {
139
- return
140
- }
141
-
142
106
  evBatteryInstantaneousChargeRate = value
143
107
  evBatteryInstantaneousChargeRateTimeStamp = (System.currentTimeMillis() / 1000L).toInt()
144
108
  isDirty = true
145
109
  }
146
110
 
147
111
  fun updateParkingBrakeOn(value: Boolean?) = synchronized(lock) {
148
- if (value == parkingBrakeOn) {
149
- return
150
- }
151
-
152
112
  parkingBrakeOn = value
153
113
  parkingBrakeOnTimestamp = (System.currentTimeMillis() / 1000L).toInt()
154
114
  isDirty = true
@@ -156,6 +116,10 @@ class AndroidAutoTelemetryHolder {
156
116
 
157
117
  fun updateBatteryLevel(levelWh: Float, capacityWh: Float) = synchronized(lock) {
158
118
  if (soe == levelWh) {
119
+ soeTimestamp = (System.currentTimeMillis() / 1000L).toInt()
120
+ batteryLevelTimestamp = soeTimestamp
121
+
122
+ isDirty = true
159
123
  return
160
124
  }
161
125
 
@@ -34,7 +34,10 @@ class SignInWithGoogleActivity : ComponentActivity() {
34
34
  val googleSignInClient = GoogleSignIn.getClient(
35
35
  this,
36
36
  GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
37
- .requestServerAuthCode(serverClientId).requestEmail().build()
37
+ .requestServerAuthCode(serverClientId)
38
+ .requestEmail()
39
+ .requestIdToken(serverClientId)
40
+ .build()
38
41
  )
39
42
  activityResultLauncher.launch(googleSignInClient.signInIntent)
40
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iternio/react-native-auto-play",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Android Auto and Apple CarPlay for react-native",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",