77 */
88package org.autoharness.cartool.property
99
10- import androidx.appfunctions.AppFunctionContext
10+ import androidx.appfunctions.AppFunction
11+ import androidx.appfunctions.AppFunctionService
12+ import androidx.appfunctions.AppFunctionServiceEntryPoint
1113import androidx.appfunctions.AppFunctionStringValueConstraint
12- import androidx.appfunctions.service.AppFunction
14+ import org.autoharness.cartool.CarToolApplication
1315
14- class CarPropertyFunctions (private val repository : CarPropertyRepository ) :
16+ @AppFunctionServiceEntryPoint(
17+ serviceName = " CarPropertyFunctionsService" ,
18+ appFunctionXmlFileName = " car_property_functions_service" ,
19+ )
20+ abstract class BaseCarPropertyFunctionsService :
21+ AppFunctionService (),
1522 GetPropertyList ,
1623 GetStringProperty ,
1724 SetStringProperty ,
@@ -30,6 +37,10 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
3037 GetFloatArrayProperty ,
3138 SetFloatArrayProperty {
3239
40+ private val repository: CarPropertyRepository
41+ get() = (applicationContext as CarToolApplication ).carPropertyRepository
42+ ? : throw IllegalStateException (" CarPropertyRepository is not initialized yet (Car service connection pending)" )
43+
3344 /* *
3445 * A list of supported vehicle properties, formatted as a JSON string.
3546 *
@@ -63,7 +74,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
6374 */
6475 @AppFunction(isDescribedByKDoc = true )
6576 override fun getPropertyList (
66- appFunctionContext : AppFunctionContext ,
6777 @AppFunctionStringValueConstraint(
6878 enumValues = [
6979 " ALL_CATEGORIES" ,
@@ -87,7 +97,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
8797 */
8898 @AppFunction(isDescribedByKDoc = true )
8999 override fun getStringProperty (
90- appFunctionContext : AppFunctionContext ,
91100 propertyName : String ,
92101 areaId : Int ,
93102 ): String = repository.getStringProperty(propertyName, areaId)
@@ -102,7 +111,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
102111 */
103112 @AppFunction(isDescribedByKDoc = true )
104113 override fun setStringProperty (
105- appFunctionContext : AppFunctionContext ,
106114 propertyName : String ,
107115 areaId : Int ,
108116 value : String ,
@@ -117,7 +125,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
117125 */
118126 @AppFunction(isDescribedByKDoc = true )
119127 override fun getBooleanProperty (
120- appFunctionContext : AppFunctionContext ,
121128 propertyName : String ,
122129 areaId : Int ,
123130 ): String = repository.getBooleanProperty(propertyName, areaId)
@@ -132,7 +139,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
132139 */
133140 @AppFunction(isDescribedByKDoc = true )
134141 override fun setBooleanProperty (
135- appFunctionContext : AppFunctionContext ,
136142 propertyName : String ,
137143 areaId : Int ,
138144 value : Boolean ,
@@ -147,7 +153,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
147153 */
148154 @AppFunction(isDescribedByKDoc = true )
149155 override fun getIntProperty (
150- appFunctionContext : AppFunctionContext ,
151156 propertyName : String ,
152157 areaId : Int ,
153158 ): String = repository.getIntProperty(propertyName, areaId)
@@ -162,7 +167,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
162167 */
163168 @AppFunction(isDescribedByKDoc = true )
164169 override fun setIntProperty (
165- appFunctionContext : AppFunctionContext ,
166170 propertyName : String ,
167171 areaId : Int ,
168172 value : Int ,
@@ -177,7 +181,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
177181 */
178182 @AppFunction(isDescribedByKDoc = true )
179183 override fun getIntArrayProperty (
180- appFunctionContext : AppFunctionContext ,
181184 propertyName : String ,
182185 areaId : Int ,
183186 ): String = repository.getIntArrayProperty(propertyName, areaId)
@@ -192,7 +195,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
192195 */
193196 @AppFunction(isDescribedByKDoc = true )
194197 override fun setIntArrayProperty (
195- appFunctionContext : AppFunctionContext ,
196198 propertyName : String ,
197199 areaId : Int ,
198200 value : IntArray ,
@@ -207,7 +209,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
207209 */
208210 @AppFunction(isDescribedByKDoc = true )
209211 override fun getLongProperty (
210- appFunctionContext : AppFunctionContext ,
211212 propertyName : String ,
212213 areaId : Int ,
213214 ): String = repository.getLongProperty(propertyName, areaId)
@@ -222,7 +223,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
222223 */
223224 @AppFunction(isDescribedByKDoc = true )
224225 override fun setLongProperty (
225- appFunctionContext : AppFunctionContext ,
226226 propertyName : String ,
227227 areaId : Int ,
228228 value : Long ,
@@ -237,7 +237,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
237237 */
238238 @AppFunction(isDescribedByKDoc = true )
239239 override fun getLongArrayProperty (
240- appFunctionContext : AppFunctionContext ,
241240 propertyName : String ,
242241 areaId : Int ,
243242 ): String = repository.getLongArrayProperty(propertyName, areaId)
@@ -252,7 +251,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
252251 */
253252 @AppFunction(isDescribedByKDoc = true )
254253 override fun setLongArrayProperty (
255- appFunctionContext : AppFunctionContext ,
256254 propertyName : String ,
257255 areaId : Int ,
258256 value : LongArray ,
@@ -267,7 +265,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
267265 */
268266 @AppFunction(isDescribedByKDoc = true )
269267 override fun getFloatProperty (
270- appFunctionContext : AppFunctionContext ,
271268 propertyName : String ,
272269 areaId : Int ,
273270 ): String = repository.getFloatProperty(propertyName, areaId)
@@ -282,7 +279,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
282279 */
283280 @AppFunction(isDescribedByKDoc = true )
284281 override fun setFloatProperty (
285- appFunctionContext : AppFunctionContext ,
286282 propertyName : String ,
287283 areaId : Int ,
288284 value : Float ,
@@ -297,7 +293,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
297293 */
298294 @AppFunction(isDescribedByKDoc = true )
299295 override fun getFloatArrayProperty (
300- appFunctionContext : AppFunctionContext ,
301296 propertyName : String ,
302297 areaId : Int ,
303298 ): String = repository.getFloatArrayProperty(propertyName, areaId)
@@ -312,7 +307,6 @@ class CarPropertyFunctions(private val repository: CarPropertyRepository) :
312307 */
313308 @AppFunction(isDescribedByKDoc = true )
314309 override fun setFloatArrayProperty (
315- appFunctionContext : AppFunctionContext ,
316310 propertyName : String ,
317311 areaId : Int ,
318312 value : FloatArray ,
0 commit comments