@@ -15,7 +15,7 @@ import org.threeten.bp.Instant
1515
1616private const val TAG = " RustInterface"
1717
18- class RustInterface (context : Context ? = null ) {
18+ class RustInterface (context : Context ? = null ) {
1919
2020 private val appContext: Context ? = context?.applicationContext
2121
@@ -50,6 +50,7 @@ class RustInterface (context: Context? = null) {
5050 external fun heartbeat (bucket_id : String , event : String , pulsetime : Double ): String
5151 external fun query (query : String , timeperiods : String ): String
5252 external fun androidQuery (timeperiods : String ): String
53+ external fun migrateHostname (hostname : String ): String
5354
5455 fun sayHello (to : String ): String {
5556 return greeting(to)
@@ -88,18 +89,18 @@ class RustInterface (context: Context? = null) {
8889
8990 fun createBucketHelper (bucket_id : String , type : String , client : String = "aw-android") {
9091 val context =
91- appContext
92- ? : throw IllegalStateException (
93- " Context is required but was not provided during initialization"
94- )
92+ appContext
93+ ? : throw IllegalStateException (
94+ " Context is required but was not provided during initialization"
95+ )
9596 val hostname = getDeviceName(context)
9697 if (bucket_id in getBucketsJSON().keys().asSequence()) {
9798 Log .i(TAG , " Bucket with ID '$bucket_id ', already existed. Not creating." )
9899 } else {
99100 val msg =
100- createBucket(
101- """ {"id": "$bucket_id ", "type": "$type ", "hostname": "$hostname ", "client": "$client "}"""
102- )
101+ createBucket(
102+ """ {"id": "$bucket_id ", "type": "$type ", "hostname": "$hostname ", "client": "$client "}"""
103+ )
103104 Log .w(TAG , msg)
104105 }
105106 }
@@ -123,11 +124,11 @@ class RustInterface (context: Context? = null) {
123124 * @param pulsetime Time window for merging events (default: 60 seconds)
124125 */
125126 fun heartbeatHelper (
126- bucket_id : String ,
127- timestamp : Instant ,
128- duration : Double ,
129- data : JSONObject ,
130- pulsetime : Double = 60.0
127+ bucket_id : String ,
128+ timestamp : Instant ,
129+ duration : Double ,
130+ data : JSONObject ,
131+ pulsetime : Double = 60.0
131132 ) {
132133 val event = Event (timestamp, duration, data)
133134 val msg = heartbeat(bucket_id, event.toString(), pulsetime)
@@ -170,9 +171,10 @@ class RustInterface (context: Context? = null) {
170171 JSONArray ()
171172 }
172173 }
174+
173175 fun getDeviceName (context : Context ): String {
174176 return Settings .Global .getString(context.contentResolver, Settings .Global .DEVICE_NAME )
175- ? : android.os.Build .MODEL ? : " Unknown"
177+ ? : android.os.Build .MODEL ? : " Unknown"
176178 }
177179
178180 fun test () {
0 commit comments