lizhanwei
2020-03-09 077c184f685b887f037ad0b83662cda88343531d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package safeluck.drive.evaluation.DB.rtktb
 
import android.content.Context
import android.text.TextUtils
import android.util.Log
import androidx.work.Worker
import androidx.work.WorkerParameters
import org.json.JSONObject
import safeluck.drive.evaluation.DB.Constant
import safeluck.drive.evaluation.DB.WorkRoomDataBase
 
class RTKConfigUpdateWorker(context:Context, workerParams: WorkerParameters) :Worker(context, workerParams){
 
    val TAG:String = "RTKConfigUpdateWorker"
 
    override fun doWork(): Result {
 
        var data = inputData.getString(Constant.RTK_CONFIG_UPDATE_JSON)
        Log.i(TAG,"更新RTK_config imei phone sn="+data)
        var imei:String=""
        var phone:String=""
        var sn:String=""
        if (!TextUtils.isEmpty(data)){
            var jsonObject: JSONObject? = null
            jsonObject = JSONObject(data)
            sn = jsonObject.getString(Constant.RTK_CONFIG_SN)
            Log.i(TAG,"sn="+sn)
            imei = sn
            phone = sn
        }
        var rtkConfigDao = WorkRoomDataBase.getWorkRoomDataBase(applicationContext).rtkConfigDao.also {
            it.update(sn, imei, phone)
        }
        return Result.success()
    }
 
 
}