Compare commits
1 Commits
dev-Issue-
...
2.1.119
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95b3a072b4 |
@@ -16,11 +16,11 @@ android {
|
|||||||
|
|
||||||
// dev - development, quality - qc, uat - User Acceptance Test, preprod - preproduction, prod - production
|
// dev - development, quality - qc, uat - User Acceptance Test, preprod - preproduction, prod - production
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "in.sminnovations.hpostesting.dev"
|
applicationId "in.sminnovations.hpostesting.quality"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 111
|
versionCode 106
|
||||||
versionName "2.1.111"
|
versionName "2.1.106"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,205 +1,45 @@
|
|||||||
{
|
{
|
||||||
"project_info": {
|
"project_info": {
|
||||||
"project_number": "650071678820",
|
"project_number": "1004619739289",
|
||||||
"project_id": "hpos-af3cc",
|
"project_id": "hpos-qa",
|
||||||
"storage_bucket": "hpos-af3cc.appspot.com"
|
"storage_bucket": "hpos-qa.appspot.com"
|
||||||
},
|
},
|
||||||
"client": [
|
"client": [
|
||||||
{
|
{
|
||||||
"client_info": {
|
"client_info": {
|
||||||
"mobilesdk_app_id": "1:650071678820:android:f1435a1c07f710036c6471",
|
"mobilesdk_app_id": "1:1004619739289:android:f669b47552748433e5c808",
|
||||||
"android_client_info": {
|
"android_client_info": {
|
||||||
"package_name": "com.example.hposconsentform"
|
"package_name": "in.sminnovations.hposregistration.quality"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"oauth_client": [
|
"oauth_client": [],
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"api_key": [
|
"api_key": [
|
||||||
{
|
{
|
||||||
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
"current_key": "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"services": {
|
"services": {
|
||||||
"appinvite_service": {
|
"appinvite_service": {
|
||||||
"other_platform_oauth_client": [
|
"other_platform_oauth_client": []
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"client_info": {
|
"client_info": {
|
||||||
"mobilesdk_app_id": "1:650071678820:android:7865bef608cdee6f6c6471",
|
"mobilesdk_app_id": "1:1004619739289:android:8397cd1f0357bd89e5c808",
|
||||||
"android_client_info": {
|
"android_client_info": {
|
||||||
"package_name": "com.smi.counselling"
|
"package_name": "in.sminnovations.hpostesting.quality"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"oauth_client": [
|
"oauth_client": [],
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"api_key": [
|
"api_key": [
|
||||||
{
|
{
|
||||||
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
"current_key": "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"services": {
|
"services": {
|
||||||
"appinvite_service": {
|
"appinvite_service": {
|
||||||
"other_platform_oauth_client": [
|
"other_platform_oauth_client": []
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"client_info": {
|
|
||||||
"mobilesdk_app_id": "1:650071678820:android:2925e9ce3417d2386c6471",
|
|
||||||
"android_client_info": {
|
|
||||||
"package_name": "in.sminnovations.hemocube"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"oauth_client": [
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-srhm9spm9hjn4frcd3r6o02gdhdbtd15.apps.googleusercontent.com",
|
|
||||||
"client_type": 1,
|
|
||||||
"android_info": {
|
|
||||||
"package_name": "in.sminnovations.hemocube",
|
|
||||||
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"api_key": [
|
|
||||||
{
|
|
||||||
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"services": {
|
|
||||||
"appinvite_service": {
|
|
||||||
"other_platform_oauth_client": [
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"client_info": {
|
|
||||||
"mobilesdk_app_id": "1:650071678820:android:7569c1cad4fc99916c6471",
|
|
||||||
"android_client_info": {
|
|
||||||
"package_name": "in.sminnovations.hposregistration"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"oauth_client": [
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-70kp5jvjda4r5diqch2kn4lc40p4f42g.apps.googleusercontent.com",
|
|
||||||
"client_type": 1,
|
|
||||||
"android_info": {
|
|
||||||
"package_name": "in.sminnovations.hposregistration",
|
|
||||||
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"api_key": [
|
|
||||||
{
|
|
||||||
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"services": {
|
|
||||||
"appinvite_service": {
|
|
||||||
"other_platform_oauth_client": [
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"client_info": {
|
|
||||||
"mobilesdk_app_id": "1:650071678820:android:f96be19e5d43102b6c6471",
|
|
||||||
"android_client_info": {
|
|
||||||
"package_name": "in.sminnovations.hpostesting"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"oauth_client": [
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-l87dnr0bdj95get0khgnvfv2an1k6ogq.apps.googleusercontent.com",
|
|
||||||
"client_type": 1,
|
|
||||||
"android_info": {
|
|
||||||
"package_name": "in.sminnovations.hpostesting",
|
|
||||||
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"api_key": [
|
|
||||||
{
|
|
||||||
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"services": {
|
|
||||||
"appinvite_service": {
|
|
||||||
"other_platform_oauth_client": [
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"client_info": {
|
|
||||||
"mobilesdk_app_id": "1:650071678820:android:a53292637abb7c0d6c6471",
|
|
||||||
"android_client_info": {
|
|
||||||
"package_name": "in.sminnovations.hpostesting.dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"oauth_client": [
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"api_key": [
|
|
||||||
{
|
|
||||||
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"services": {
|
|
||||||
"appinvite_service": {
|
|
||||||
"other_platform_oauth_client": [
|
|
||||||
{
|
|
||||||
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
|
||||||
"client_type": 3
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,8 +119,13 @@
|
|||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
<category android:name="android.intent.category.HOME" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.MONKEY"/>
|
||||||
|
<category android:name="android.intent.category.LAUNCHER_APP" />
|
||||||
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
package com.example.hpostesting.data.api
|
package com.example.hpostesting.data.api
|
||||||
|
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
|
||||||
import com.example.hpostesting.presentation.UsbServiceListener
|
|
||||||
|
|
||||||
interface PropertyProvider {
|
interface PropertyProvider {
|
||||||
|
|
||||||
fun getProperty(key: String): String
|
fun getProperty(key: String): String
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DeviceCommunicationHandler {
|
|
||||||
fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener)
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@ import com.example.hpostesting.data.model.patient.DeviceData
|
|||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
|
||||||
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class], version = 26, exportSchema = false)
|
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class], version = 24, exportSchema = false)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class MyDatabase : RoomDatabase() {
|
abstract class MyDatabase : RoomDatabase() {
|
||||||
abstract fun userDao(): UserDao
|
abstract fun userDao(): UserDao
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.example.hpostesting.data.model.deviceprovision
|
|
||||||
|
|
||||||
data class ProvisionData(
|
|
||||||
val username: String?,
|
|
||||||
val password: String?,
|
|
||||||
val natsToken: String?
|
|
||||||
)
|
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
|
|
||||||
data class MolbioV2Result(
|
data class MolbioV2Result(
|
||||||
val age: Int? = 31,
|
val age: Int? = 31,
|
||||||
val analysisDate: String? = "2024-02-08 16:33:56",
|
val analysisDate: String? = "",
|
||||||
val analysisId: String? = "",
|
val analysisId: String? = "",
|
||||||
val analysisStatus: String? = "",
|
val analysisStatus: String? = "",
|
||||||
val analysisType: String? = "HPOS",
|
val analysisType: String? = "HPOS",
|
||||||
@@ -12,11 +12,11 @@ data class MolbioV2Result(
|
|||||||
val bloodGroup: String? = "",
|
val bloodGroup: String? = "",
|
||||||
val coefficients: List<Int>? = listOf(22, 22),
|
val coefficients: List<Int>? = listOf(22, 22),
|
||||||
val collectionLocation: List<Any>? = listOf(),
|
val collectionLocation: List<Any>? = listOf(),
|
||||||
val collectionTime: String? = "2024-02-08 16:33:56",
|
val collectionTime: String? = "",
|
||||||
val collector: String? = "",
|
val collector: String? = "",
|
||||||
val curveFitting: String? = "Linear",
|
val curveFitting: String? = "Linear",
|
||||||
val deviceName: String? = "HPOS",
|
val deviceName: String? = "HPOS",
|
||||||
val expiryTime: String? = "2024-02-08 16:33:56",
|
val expiryTime: String? = "",
|
||||||
val gender: String? = "",
|
val gender: String? = "",
|
||||||
val interpretation: String? = "",
|
val interpretation: String? = "",
|
||||||
val `operator`: String? = "",
|
val `operator`: String? = "",
|
||||||
@@ -30,7 +30,7 @@ data class MolbioV2Result(
|
|||||||
val testId: String? = "",
|
val testId: String? = "",
|
||||||
val testResult: String? = "",
|
val testResult: String? = "",
|
||||||
val testStatus: String? = "",
|
val testStatus: String? = "",
|
||||||
val testTime: String? = "2024-02-08 16:33:56",
|
val testTime: String? = "",
|
||||||
val testType: String? = "",
|
val testType: String? = "",
|
||||||
val thresholds: String? = "",
|
val thresholds: String? = "",
|
||||||
val underMedication: Boolean? = false,
|
val underMedication: Boolean? = false,
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
|
|
||||||
data class MolbioV2ResultData(
|
data class MolbioV2ResultData(
|
||||||
val age: Int? = 0,
|
val age: Int? = 0,
|
||||||
val analysisDate: String? = "2024-02-08 16:33:56",
|
val analysisDate: String? = "",
|
||||||
val analysisStatus: String? = "",
|
val analysisStatus: String? = "",
|
||||||
val analysisType: String? = "",
|
val analysisType: String? = "",
|
||||||
val analysisTypeMethod: String? = "",
|
val analysisTypeMethod: String? = "",
|
||||||
val bloodGroup: String? = "",
|
val bloodGroup: String? = "",
|
||||||
val coefficients: List<Int>? = listOf(),
|
val coefficients: List<Int>? = listOf(),
|
||||||
val collectionLocation: List<Any>? = listOf(),
|
val collectionLocation: List<Any>? = listOf(),
|
||||||
val collectionTime: String? = "2024-02-08 16:33:56",
|
val collectionTime: String? = "",
|
||||||
val collector: String? = "",
|
val collector: String? = "",
|
||||||
val createdAt: String? = "",
|
val createdAt: String? = "",
|
||||||
val createdBy: Int? = 0,
|
val createdBy: Int? = 0,
|
||||||
val curveFitting: String? = "",
|
val curveFitting: String? = "",
|
||||||
val deviceId: Int? = 0,
|
val deviceId: Int? = 0,
|
||||||
val expiryTime: String? = "2024-02-08 16:33:56",
|
val expiryTime: String? = "",
|
||||||
val gender: String? = "",
|
val gender: String? = "",
|
||||||
val id: Int? = 0,
|
val id: Int? = 0,
|
||||||
val interpretation: String? = "",
|
val interpretation: String? = "",
|
||||||
@@ -32,7 +32,7 @@ data class MolbioV2ResultData(
|
|||||||
val testId: String? = "",
|
val testId: String? = "",
|
||||||
val testResult: String? = "",
|
val testResult: String? = "",
|
||||||
val testStatus: String? = "",
|
val testStatus: String? = "",
|
||||||
val testTime: String? = "2024-02-08 16:33:56",
|
val testTime: String? = "",
|
||||||
val testType: String? = "",
|
val testType: String? = "",
|
||||||
val thresholds: String? = "",
|
val thresholds: String? = "",
|
||||||
val underMedication: Boolean? = false,
|
val underMedication: Boolean? = false,
|
||||||
|
|||||||
@@ -15,15 +15,5 @@ data class DeviceData(
|
|||||||
@get:PropertyName("coefficients") @set:PropertyName("coefficients")
|
@get:PropertyName("coefficients") @set:PropertyName("coefficients")
|
||||||
var coefficients: List<Double> = emptyList(),
|
var coefficients: List<Double> = emptyList(),
|
||||||
@get:PropertyName("calibratedAt") @set:PropertyName("calibratedAt")
|
@get:PropertyName("calibratedAt") @set:PropertyName("calibratedAt")
|
||||||
var calibratedAt: String = "" ,
|
var calibratedAt: String = ""
|
||||||
@get:PropertyName("deviceProvisionResponse") @set:PropertyName("deviceProvisionResponse")
|
|
||||||
var deviceProvisionResponse: String = "" ,
|
|
||||||
@get:PropertyName("username") @set:PropertyName("username")
|
|
||||||
var username: String = "",
|
|
||||||
@get:PropertyName("password") @set:PropertyName("password")
|
|
||||||
var password: String = "",
|
|
||||||
@get:PropertyName("natsToken") @set:PropertyName("natsToken")
|
|
||||||
var natsToken: String = "",
|
|
||||||
@get:PropertyName("natsTokenExpiry") @set:PropertyName("natsTokenExpiry")
|
|
||||||
var natsTokenExpiry: String = ""
|
|
||||||
)
|
)
|
||||||
@@ -206,31 +206,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
return allDeviceDataList.find { it.deviceId == deviceId }
|
return allDeviceDataList.find { it.deviceId == deviceId }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getDeviceResponse(data: DeviceData?): Response<String> {
|
|
||||||
return try {
|
|
||||||
db.collection("devices").add(data!!).await()
|
|
||||||
Response.Success(data.deviceProvisionResponse)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Firebase.crashlytics.recordException(e)
|
|
||||||
Response.Error(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override suspend fun uploadDeviceId(data: DeviceData): Response<String>? {
|
|
||||||
return try {
|
|
||||||
db.collection("devices").add(data!!).await()
|
|
||||||
Response.Success(data.deviceId)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Firebase.crashlytics.recordException(e)
|
|
||||||
Response.Error(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <UserData> addTestToDatabase(testDetails: UserData): Any {
|
override fun <UserData> addTestToDatabase(testDetails: UserData): Any {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,8 +32,6 @@ interface Repository {
|
|||||||
suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean>
|
suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean>
|
||||||
|
|
||||||
suspend fun getDeviceDataById(deviceId: String): DeviceData?
|
suspend fun getDeviceDataById(deviceId: String): DeviceData?
|
||||||
suspend fun getDeviceResponse(data: DeviceData?): Response<String>
|
|
||||||
suspend fun uploadDeviceId(data: DeviceData): Response<String>?
|
|
||||||
abstract fun <UserData> addTestToDatabase(testDetails: UserData): Any
|
abstract fun <UserData> addTestToDatabase(testDetails: UserData): Any
|
||||||
// suspend fun addToDatabase(data: PatientDetails)
|
// suspend fun addToDatabase(data: PatientDetails)
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
if (mScannerInfoList.isNotEmpty()) {
|
if (mScannerInfoList.isNotEmpty()) {
|
||||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this,"Scanner Is not available In this device", Toast.LENGTH_LONG).show()
|
Toast.makeText(this,"Error", Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,15 +149,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Constants.DEVICE_TYPE_HEMOCUBE
|
Constants.DEVICE_TYPE_HEMOCUBE
|
||||||
}
|
}
|
||||||
|
|
||||||
device.productId == 4614 && device.vendorId == 7111 -> {
|
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
|
||||||
binding.cvItem3.visibility = View.VISIBLE
|
|
||||||
binding.cvItem2.visibility = View.GONE
|
|
||||||
binding.cvItem4.visibility = View.GONE
|
|
||||||
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
|
||||||
Constants.DEVICE_TYPE_HEMOCUBE
|
|
||||||
}
|
|
||||||
|
|
||||||
device.productId == Constants.DEVICE_PRODUCT_ID && device.vendorId == Constants.DEVICE_VENDOR_ID -> {
|
device.productId == Constants.DEVICE_PRODUCT_ID && device.vendorId == Constants.DEVICE_VENDOR_ID -> {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package com.example.hpostesting.presentation
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import io.nats.client.AuthHandler
|
import io.nats.client.AuthHandler
|
||||||
import io.nats.client.Connection
|
import io.nats.client.Connection
|
||||||
@@ -13,15 +12,20 @@ import io.nats.client.NKey
|
|||||||
import io.nats.client.Nats
|
import io.nats.client.Nats
|
||||||
import io.nats.client.Options
|
import io.nats.client.Options
|
||||||
import io.nats.client.support.SSLUtils
|
import io.nats.client.support.SSLUtils
|
||||||
|
import java.io.BufferedInputStream
|
||||||
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
import java.nio.file.Paths
|
||||||
import java.security.GeneralSecurityException
|
import java.security.GeneralSecurityException
|
||||||
import java.security.KeyStore
|
import java.security.KeyStore
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
import java.security.cert.CertificateFactory
|
import java.security.cert.CertificateFactory
|
||||||
|
import javax.net.ssl.KeyManager
|
||||||
import javax.net.ssl.KeyManagerFactory
|
import javax.net.ssl.KeyManagerFactory
|
||||||
import javax.net.ssl.SSLContext
|
import javax.net.ssl.SSLContext
|
||||||
|
import javax.net.ssl.TrustManager
|
||||||
import javax.net.ssl.TrustManagerFactory
|
import javax.net.ssl.TrustManagerFactory
|
||||||
|
|
||||||
|
|
||||||
@@ -31,7 +35,6 @@ class NatsManager(datacollector: DashboardActivity) {
|
|||||||
var nc: Connection? = null
|
var nc: Connection? = null
|
||||||
val datacollector = datacollector
|
val datacollector = datacollector
|
||||||
var connect = false
|
var connect = false
|
||||||
var sharedPreferences = datacollector.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
|
|
||||||
private fun createSSLContext(): SSLContext {
|
private fun createSSLContext(): SSLContext {
|
||||||
val keyStorePassword = "prime24".toCharArray() // Change as necessary
|
val keyStorePassword = "prime24".toCharArray() // Change as necessary
|
||||||
@@ -42,8 +45,7 @@ class NatsManager(datacollector: DashboardActivity) {
|
|||||||
FileInputStream(clientCertPath).use { keyStoreInputStream ->
|
FileInputStream(clientCertPath).use { keyStoreInputStream ->
|
||||||
keyStore.load(keyStoreInputStream, keyStorePassword)
|
keyStore.load(keyStoreInputStream, keyStorePassword)
|
||||||
}
|
}
|
||||||
val caCertPath =
|
val caCertPath = "/storage/sdcard0/Android/data/in.sminnovations.hpostesting.quality/files/NATS/clientCertificate/client-cert.pem"
|
||||||
"/storage/sdcard0/Android/data/in.sminnovations.hpostesting.quality/files/NATS/clientCertificate/client-cert.pem"
|
|
||||||
val caCert = FileInputStream(caCertPath).use { inputStream ->
|
val caCert = FileInputStream(caCertPath).use { inputStream ->
|
||||||
val certificateFactory = CertificateFactory.getInstance("X.509")
|
val certificateFactory = CertificateFactory.getInstance("X.509")
|
||||||
certificateFactory.generateCertificate(inputStream)
|
certificateFactory.generateCertificate(inputStream)
|
||||||
@@ -69,116 +71,107 @@ class NatsManager(datacollector: DashboardActivity) {
|
|||||||
return sslContext
|
return sslContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
fun connect() {
|
fun connect() {
|
||||||
Log.d(TAG, "TRY TO CONNECT")
|
Log.d(TAG, "TRY TO CONNECT")
|
||||||
Thread {
|
Thread {
|
||||||
|
|
||||||
|
val seedString = "SUAJH5VMO6GDRQA6QTXCLIJMS74IWIUTU3NJVYIOTZF2LBWUPD77DA2ZEA"
|
||||||
|
Log.e("seedString",seedString)
|
||||||
|
val seedBytes = seedString.toCharArray()
|
||||||
|
|
||||||
|
val theNKey = NKey.fromSeed(seedBytes) // really should load from somewhere
|
||||||
|
|
||||||
|
val options = Options.Builder()
|
||||||
|
.server("nats://nanodgx.in:4222")
|
||||||
|
.sslContext(SSLUtils.createOpenTLSContext())
|
||||||
|
.authHandler(object : AuthHandler {
|
||||||
|
override fun getID(): CharArray? {
|
||||||
|
return try {
|
||||||
|
theNKey?.publicKey
|
||||||
|
} catch (ex: GeneralSecurityException) {
|
||||||
|
null
|
||||||
|
} catch (ex: IOException) {
|
||||||
|
null
|
||||||
|
} catch (ex: NullPointerException) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sign(nonce: ByteArray): ByteArray? {
|
||||||
|
return try {
|
||||||
|
theNKey?.sign(nonce)
|
||||||
|
} catch (ex: GeneralSecurityException) {
|
||||||
|
null
|
||||||
|
} catch (ex: IOException) {
|
||||||
|
null
|
||||||
|
} catch (ex: NullPointerException) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getJWT(): CharArray? {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
val seedString = sharedPreferences.getString(Constants.NATS_TOKEN, "")
|
|
||||||
val deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
|
||||||
Log.e("seedString", seedString.toString())
|
|
||||||
Log.d("nats deviceId", deviceId.toString())
|
|
||||||
val seedBytes = seedString?.toCharArray()
|
|
||||||
|
|
||||||
val theNKey = NKey.fromSeed(seedBytes) // really should load from somewhere
|
|
||||||
|
|
||||||
val options = Options.Builder()
|
|
||||||
.server("nats://nanodgx.in:4222")
|
|
||||||
.sslContext(SSLUtils.createOpenTLSContext())
|
|
||||||
.authHandler(object : AuthHandler {
|
|
||||||
override fun getID(): CharArray? {
|
|
||||||
return try {
|
|
||||||
theNKey?.publicKey
|
|
||||||
} catch (ex: GeneralSecurityException) {
|
|
||||||
null
|
|
||||||
} catch (ex: IOException) {
|
|
||||||
null
|
|
||||||
} catch (ex: NullPointerException) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun sign(nonce: ByteArray): ByteArray? {
|
|
||||||
return try {
|
|
||||||
theNKey?.sign(nonce)
|
|
||||||
} catch (ex: GeneralSecurityException) {
|
|
||||||
null
|
|
||||||
} catch (ex: IOException) {
|
|
||||||
null
|
|
||||||
} catch (ex: NullPointerException) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getJWT(): CharArray? {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build()
|
|
||||||
|
|
||||||
nc = Nats.connect(options)
|
nc = Nats.connect(options)
|
||||||
Log.d(TAG, "Connected to Nats server ${options.servers.first()}")
|
Log.d(TAG, "Connected to Nats server ${options.servers.first()}")
|
||||||
connect = true
|
connect = true
|
||||||
datacollector.setConnect(true)
|
datacollector.setConnect(true)
|
||||||
|
|
||||||
if (nc?.status == Connection.Status.CONNECTED) {
|
if (nc?.status == Connection.Status.CONNECTED) {
|
||||||
Log.d("NATSCONNECTION", "NATS is successfully connected.")
|
Log.e("NATSCONNECTION", "NATS is successfully connected.")
|
||||||
|
|
||||||
val d = nc?.createDispatcher { msg: Message? ->
|
|
||||||
println("Nats dispatcher $msg")
|
|
||||||
}
|
|
||||||
|
|
||||||
nc?.subscribe("device.hpos.${deviceId}.ping")
|
|
||||||
|
|
||||||
nc?.publish(
|
|
||||||
"server.hpos.${deviceId}.ping",
|
|
||||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
|
||||||
)
|
|
||||||
nc?.publish(
|
|
||||||
"server.hpos.${deviceId}.health",
|
|
||||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
|
||||||
)
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.${deviceId}.ping") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response)
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
Log.d(TAG, "subscribed msg ${msg} on topic ping")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.${deviceId}.update") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response)
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.${deviceId}.uploadlogs") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response + "UPLOAD")
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.${deviceId}.disable") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response)
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.${deviceId}.updatecustomer") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response)
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe("device.hpos.${deviceId}.checkupdate") { msg ->
|
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
|
||||||
datacollector.setResponse(response)
|
|
||||||
println("Message received (up to 100 times): $response")
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Log.d("NATSCONNECTION", "NATS is not connected. Current status: ${nc?.status}")
|
Log.e("NATSCONNECTION", "NATS is not connected. Current status: ${nc?.status}")
|
||||||
|
}
|
||||||
|
|
||||||
|
nc?.publish(
|
||||||
|
"server.hpos.HCV-000-3001.ping",
|
||||||
|
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
||||||
|
)
|
||||||
|
nc?.publish(
|
||||||
|
"server.hpos.HCV-000-3001.health",
|
||||||
|
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
||||||
|
)
|
||||||
|
Log.d(TAG, "Published msg server.hpos.HCV-000-3001.ping on topic Testing")
|
||||||
|
val d = nc?.createDispatcher { msg: Message? ->
|
||||||
|
println("PRITIMOI SARKAR $msg")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
d?.subscribe("device.hpos.HCV-000-3001.update") { msg ->
|
||||||
|
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||||
|
datacollector.setResponse(response)
|
||||||
|
println("Message received (up to 100 times): $response")
|
||||||
|
}
|
||||||
|
|
||||||
|
d?.subscribe("device.hpos.HCV-000-3001.uploadlogs") { msg ->
|
||||||
|
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||||
|
datacollector.setResponse(response + "uPLOAD")
|
||||||
|
println("Message received (up to 100 times): $response")
|
||||||
|
}
|
||||||
|
|
||||||
|
d?.subscribe("device.hpos.HCV-000-3001.disable") { msg ->
|
||||||
|
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||||
|
datacollector.setResponse(response)
|
||||||
|
println("Message received (up to 100 times): $response")
|
||||||
|
}
|
||||||
|
|
||||||
|
d?.subscribe("device.hpos.HCV-000-3001.updatecustomer") { msg ->
|
||||||
|
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||||
|
datacollector.setResponse(response)
|
||||||
|
println("Message received (up to 100 times): $response")
|
||||||
|
}
|
||||||
|
|
||||||
|
d?.subscribe("device.hpos.HCV-000-3001.checkupdate") { msg ->
|
||||||
|
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||||
|
datacollector.setResponse(response)
|
||||||
|
println("Message received (up to 100 times): $response")
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (exp: Exception) {
|
} catch (exp: Exception) {
|
||||||
@@ -195,16 +188,6 @@ class NatsManager(datacollector: DashboardActivity) {
|
|||||||
Log.d(TAG, "Published msg ${msg} on topic ${topic}")
|
Log.d(TAG, "Published msg ${msg} on topic ${topic}")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sub(topic: String) {
|
|
||||||
val d = nc?.createDispatcher { msg: Message? ->
|
|
||||||
val response = String(msg?.data ?: ByteArray(0), StandardCharsets.UTF_8)
|
|
||||||
datacollector.onMessageReceived(topic, response)
|
|
||||||
Log.d(TAG, "Subscribed msg $msg on topic $topic")
|
|
||||||
}
|
|
||||||
|
|
||||||
d?.subscribe(topic)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun close() {
|
fun close() {
|
||||||
nc?.close()
|
nc?.close()
|
||||||
Log.d(TAG, "Nats connection close")
|
Log.d(TAG, "Nats connection close")
|
||||||
|
|||||||
@@ -3,14 +3,19 @@ package com.example.hpostesting.presentation.assurance
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import com.example.hpostesting.presentation.NatsManager
|
||||||
|
import com.example.hpostesting.presentation.dashboard.IDataCollector
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityAssuranceControlsBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityAssuranceControlsBinding
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class AssuranceControlsActivity: AppCompatActivity() {
|
class AssuranceControlsActivity: AppCompatActivity(), IDataCollector {
|
||||||
lateinit var binding: ActivityAssuranceControlsBinding
|
lateinit var binding: ActivityAssuranceControlsBinding
|
||||||
lateinit var sharedPreference: SharedPreferences
|
lateinit var sharedPreference: SharedPreferences
|
||||||
|
lateinit var nats: NatsManager
|
||||||
|
var responses: String = ""
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -24,5 +29,21 @@ class AssuranceControlsActivity: AppCompatActivity() {
|
|||||||
.replace(binding.fgAssuranceControls.id, AssuranceControlsFragment())
|
.replace(binding.fgAssuranceControls.id, AssuranceControlsFragment())
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nats = NatsManager(this)
|
||||||
|
// nats.connect()
|
||||||
|
// nats.pub("server.hpos.HCV-000-3001.ping", "THIS IS A TEST MSG")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setConnect(connect: Boolean) {
|
||||||
|
if(connect){
|
||||||
|
Log.i("NATS Connection", connect.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setResponse(response: String) {
|
||||||
|
|
||||||
|
responses = responses+response+"\n"
|
||||||
|
println(responses)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,7 @@ import android.app.DownloadManager
|
|||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
@@ -21,7 +19,6 @@ import androidx.navigation.ui.navigateUp
|
|||||||
import androidx.navigation.ui.setupActionBarWithNavController
|
import androidx.navigation.ui.setupActionBarWithNavController
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
import com.example.hpostesting.data.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.NatsManager
|
import com.example.hpostesting.presentation.NatsManager
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
@@ -35,22 +32,15 @@ import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
|||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
interface NatsMessageCallback {
|
open interface IDataCollector {
|
||||||
fun onMessageReceived(topic: String, message: String)
|
|
||||||
}
|
|
||||||
|
|
||||||
open interface IDataCollector: NatsMessageCallback {
|
|
||||||
fun setConnect(connect: Boolean)
|
fun setConnect(connect: Boolean)
|
||||||
fun setResponse(response: String)
|
fun setResponse(response: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||||
|
|
||||||
val TAG = "DashboardActivity"
|
|
||||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||||
private lateinit var binding: ActivityDashboardBinding
|
private lateinit var binding: ActivityDashboardBinding
|
||||||
lateinit var sharedPreferences: SharedPreferences
|
|
||||||
var responses: String = ""
|
var responses: String = ""
|
||||||
lateinit var nats: NatsManager
|
lateinit var nats: NatsManager
|
||||||
private var downloadId: Long = 0
|
private var downloadId: Long = 0
|
||||||
@@ -63,27 +53,15 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
super.attachBaseContext(newBase)
|
super.attachBaseContext(newBase)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMessageReceived(topic: String, message: String) {
|
|
||||||
// Handle incoming messages from NATS
|
|
||||||
Log.d(TAG, "Received message on topic $topic: $message")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||||
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setSupportActionBar(binding.appBarDashboard.toolbar)
|
setSupportActionBar(binding.appBarDashboard.toolbar)
|
||||||
nats = NatsManager(this)
|
nats = NatsManager(this)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
nats.connect()
|
||||||
nats.connect()
|
nats.pub("server.hpos.HCV-000-3001.ping", "THIS IS A TEST MSG")
|
||||||
}
|
|
||||||
|
|
||||||
val deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
|
||||||
|
|
||||||
nats.sub("server.hpos.${deviceId}.ping")
|
|
||||||
nats.pub("server.hpos.${deviceId}.ping", "THIS IS A TEST MSG")
|
|
||||||
|
|
||||||
hemocubeViewModel.deviceUpdate.observe(this) { result ->
|
hemocubeViewModel.deviceUpdate.observe(this) { result ->
|
||||||
when (result) {
|
when (result) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class GalleryFragment : Fragment() {
|
|||||||
) {
|
) {
|
||||||
binding.btnDeviceProvision.visibility = View.VISIBLE
|
binding.btnDeviceProvision.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
binding.btnDeviceProvision.visibility = View.VISIBLE
|
binding.btnDeviceProvision.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnDeviceProvision.setOnClickListener {
|
binding.btnDeviceProvision.setOnClickListener {
|
||||||
|
|||||||
@@ -19,20 +19,16 @@ import androidx.fragment.app.activityViewModels
|
|||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.api.DeviceCommunicationHandler
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
|
||||||
import com.example.hpostesting.data.model.login.LoginRequest
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
import com.example.hpostesting.data.model.login.LoginResponse
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2Result
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2Result
|
||||||
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultRequest
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultRequest
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.presentation.KitScanActivity
|
import com.example.hpostesting.presentation.KitScanActivity
|
||||||
import com.example.hpostesting.presentation.UsbServiceListener
|
|
||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
||||||
@@ -53,7 +49,7 @@ import java.io.BufferedOutputStream
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.nio.charset.Charset
|
import java.net.URL
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@@ -74,10 +70,6 @@ class HomeFragment : Fragment() {
|
|||||||
private val homeViewModel: HemoCubeViewModel by activityViewModels()
|
private val homeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
|
|
||||||
private var isTokenAvailable = false
|
private var isTokenAvailable = false
|
||||||
private var natsToken: String = ""
|
|
||||||
private var deviceId: String = ""
|
|
||||||
|
|
||||||
|
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
@@ -104,7 +96,7 @@ class HomeFragment : Fragment() {
|
|||||||
binding.labelQuickCapture.visibility = View.VISIBLE
|
binding.labelQuickCapture.visibility = View.VISIBLE
|
||||||
binding.btnQuickCapture.visibility = View.VISIBLE
|
binding.btnQuickCapture.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
getDeviceId()
|
|
||||||
checkUnprocessedCSVData()
|
checkUnprocessedCSVData()
|
||||||
viewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
viewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
deleteIncompleteRegistrations(userData)
|
deleteIncompleteRegistrations(userData)
|
||||||
@@ -125,57 +117,17 @@ class HomeFragment : Fragment() {
|
|||||||
binding.rvOrderOffline.adapter = adapter
|
binding.rvOrderOffline.adapter = adapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) { deviceData ->
|
|
||||||
val devicelist = mutableListOf<DeviceData>()
|
|
||||||
if (deviceData != null) {
|
|
||||||
devicelist.add(DeviceData(deviceData.deviceId))
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
viewModel.networkStatusLiveData?.observe(viewLifecycleOwner) { isConnected ->
|
viewModel.networkStatusLiveData?.observe(viewLifecycleOwner) { isConnected ->
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
|
|
||||||
binding.internetAvailableCL.visibility = View.VISIBLE
|
binding.internetAvailableCL.visibility = View.VISIBLE
|
||||||
binding.internetNotAvailableCL.visibility = View.GONE
|
binding.internetNotAvailableCL.visibility = View.GONE
|
||||||
binding.pendingTest.visibility = View.VISIBLE
|
|
||||||
loadUserData()
|
loadUserData()
|
||||||
setSearch()
|
setSearch()
|
||||||
checkForLocalDBData()
|
checkForLocalDBData()
|
||||||
checkForTokenAndUpdate()
|
checkForTokenAndUpdate()
|
||||||
|
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
|
||||||
val resultList = MolbioV2ResultRequest(mutableListOf(MolbioV2Result()))
|
|
||||||
userDataList.forEach { userData ->
|
|
||||||
if (!userData.molbioFlag && isTokenAvailable) {
|
|
||||||
resultList.results?.add(
|
|
||||||
MolbioV2Result(
|
|
||||||
rawData = userData,
|
|
||||||
analysisId = userData._id,
|
|
||||||
analysisDate = "2024-02-08 16:33:56",//userData.testTime,
|
|
||||||
analysisStatus = userData.classificationResult,
|
|
||||||
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(),
|
|
||||||
interpretation = userData.classificationResult,
|
|
||||||
testId = userData._id,
|
|
||||||
testTime = "2024-02-08 16:33:56",//userData.testTime,
|
|
||||||
collectionTime = "2024-02-08 16:33:56",//userData.testTime,
|
|
||||||
expiryTime = "2024-02-08 16:33:56"//userData.testTime,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
userData.molbioFlag = true
|
|
||||||
hemoCubeViewModel.uploadResult(resultList)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!userData.localFlag) {
|
|
||||||
userData.localFlag = true
|
|
||||||
hemoCubeViewModel.bulkAddResultTestToDb(userData)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
binding.internetAvailableCL.visibility = View.GONE
|
binding.internetAvailableCL.visibility = View.GONE
|
||||||
binding.pendingTest.visibility = View.GONE
|
|
||||||
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
||||||
setUserId()
|
setUserId()
|
||||||
}
|
}
|
||||||
@@ -195,17 +147,18 @@ class HomeFragment : Fragment() {
|
|||||||
logoutUser(requireContext())
|
logoutUser(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.uploadData.setOnClickListener {
|
binding.uploadData.setOnClickListener {
|
||||||
showUploadDialog(requireContext())
|
showUploadDialog(requireContext())
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
|
|
||||||
val btnSaveLocalVisibility =
|
val btnSaveLocalVisibility =
|
||||||
if (userData.any { it.testStatus == true }) View.GONE else View.GONE
|
if (userData.any { it.testStatus == true }) View.VISIBLE else View.GONE
|
||||||
|
|
||||||
binding.downloadCSV.visibility = btnSaveLocalVisibility
|
binding.btnSaveLocal.visibility = btnSaveLocalVisibility
|
||||||
|
|
||||||
binding.downloadCSV.setOnClickListener {
|
binding.btnSaveLocal.setOnClickListener {
|
||||||
if (btnSaveLocalVisibility == View.VISIBLE) {
|
if (btnSaveLocalVisibility == View.VISIBLE) {
|
||||||
// Execute the action when the button is visible (testStatus is true for at least one user)
|
// Execute the action when the button is visible (testStatus is true for at least one user)
|
||||||
showDownloadDialog(requireContext())
|
showDownloadDialog(requireContext())
|
||||||
@@ -219,8 +172,6 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.btnNewKit.setOnClickListener {
|
binding.btnNewKit.setOnClickListener {
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.KIT_NUMBER, "")
|
putString(Constants.KIT_NUMBER, "")
|
||||||
@@ -242,48 +193,27 @@ class HomeFragment : Fragment() {
|
|||||||
binding.downloadCSV.setOnClickListener {
|
binding.downloadCSV.setOnClickListener {
|
||||||
showDownloadDialog(requireContext())
|
showDownloadDialog(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForTokenAndUpdate() {
|
private fun checkForTokenAndUpdate() {
|
||||||
var accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
||||||
var password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString()
|
val password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString()
|
||||||
var userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
val userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
||||||
deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").toString()
|
|
||||||
Log.e("idpass", userID)
|
|
||||||
Log.e("idpass", password)
|
|
||||||
Log.e("idpass", deviceId)
|
|
||||||
if (userID.isNotEmpty() && password.isNotEmpty()) {
|
if (userID.isNotEmpty() && password.isNotEmpty()) {
|
||||||
if (!isTokenAvailable) {
|
if (accessToken.isEmpty()) {
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
} else {
|
} else {
|
||||||
if (isTokenExpired(accessToken)) {
|
if (isTokenExpired(accessToken)) {
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
} else {
|
} else {
|
||||||
isTokenAvailable = true
|
isTokenAvailable = true
|
||||||
|
|
||||||
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
||||||
hemoCubeViewModel.uploadLogs()
|
hemoCubeViewModel.uploadLogs()
|
||||||
hemoCubeViewModel.startPeriodicCheckUpdate()
|
hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||||
hemoCubeViewModel.downloadClientCertificate()
|
hemoCubeViewModel.downloadClientCertificate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if (deviceId.isNotEmpty()) {
|
} else {
|
||||||
fetchDeviceCredentials()
|
|
||||||
// This code will execute after credentials have been successfully fetched and stored.
|
|
||||||
userID = sharedPreference.getString("username", "").toString()
|
|
||||||
password = sharedPreference.getString("password", "").toString()
|
|
||||||
accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
|
||||||
if (accessToken.isEmpty()) {
|
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
|
||||||
} else {
|
|
||||||
// Continue with your existing logic if the token is not empty.
|
|
||||||
isTokenAvailable = true
|
|
||||||
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
|
||||||
hemoCubeViewModel.uploadLogs()
|
|
||||||
hemoCubeViewModel.startPeriodicCheckUpdate()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
"Contact Help and get your device provision done",
|
"Contact Help and get your device provision done",
|
||||||
@@ -291,6 +221,10 @@ class HomeFragment : Fragment() {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
@@ -537,48 +471,6 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun fetchDeviceCredentials() {
|
|
||||||
try {
|
|
||||||
val db = Firebase.firestore
|
|
||||||
// Ensure deviceId is not null or empty
|
|
||||||
val deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").takeIf { it!!.isNotBlank() }
|
|
||||||
?: throw IllegalStateException("Device ID is missing or blank.")
|
|
||||||
|
|
||||||
val deviceRef = db.collection("devices").whereEqualTo("deviceId", deviceId)
|
|
||||||
|
|
||||||
deviceRef.get()
|
|
||||||
.addOnSuccessListener { documentSnapshot ->
|
|
||||||
if (!documentSnapshot.isEmpty) {
|
|
||||||
val deviceData = documentSnapshot.documents[0].toObject(DeviceData::class.java)
|
|
||||||
deviceData?.let { data ->
|
|
||||||
val username = data.username
|
|
||||||
val password = data.password
|
|
||||||
val natsToken = data.natsToken
|
|
||||||
// Log for debugging
|
|
||||||
Log.d("fetchDeviceCredentials", "Username: $username, Password: $password")
|
|
||||||
// Save credentials in SharedPreferences
|
|
||||||
with(sharedPreference.edit()) {
|
|
||||||
putString("username", username)
|
|
||||||
putString("password", password)
|
|
||||||
putString(Constants.NATS_TOKEN, natsToken)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
hemoCubeViewModel.login(createLoginRequestData(username, password))
|
|
||||||
} ?: Log.e("fetchDeviceCredentials", "Failed to parse device data.")
|
|
||||||
} else {
|
|
||||||
Log.e("fetchDeviceCredentials", "Document does not exist.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.addOnFailureListener { exception ->
|
|
||||||
Log.e("fetchDeviceCredentials", "Error fetching device data", exception)
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("fetchDeviceCredentials", "Error in fetchDeviceCredentials", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun loadUserData() {
|
private fun loadUserData() {
|
||||||
try {
|
try {
|
||||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd")
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd")
|
||||||
@@ -748,7 +640,7 @@ class HomeFragment : Fragment() {
|
|||||||
private fun checkUnprocessedCSVData() {
|
private fun checkUnprocessedCSVData() {
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
val downloadDataVisibility =
|
val downloadDataVisibility =
|
||||||
if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.GONE else View.GONE
|
if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.VISIBLE else View.GONE
|
||||||
binding.downloadCSV.visibility = downloadDataVisibility
|
binding.downloadCSV.visibility = downloadDataVisibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -803,6 +695,36 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
|
val resultList = MolbioV2ResultRequest(mutableListOf(MolbioV2Result()))
|
||||||
|
userDataList.forEach { userData ->
|
||||||
|
if (!userData.localFlag) {
|
||||||
|
userData.localFlag = true
|
||||||
|
hemoCubeViewModel.bulkAddResultTestToDb(userData)
|
||||||
|
if (!userData.molbioFlag && isTokenAvailable) {
|
||||||
|
resultList.results?.add(
|
||||||
|
MolbioV2Result(
|
||||||
|
rawData = userData,
|
||||||
|
analysisId = userData._id,
|
||||||
|
analysisDate = userData.testTime,
|
||||||
|
analysisStatus = userData.classificationResult,
|
||||||
|
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(),
|
||||||
|
interpretation = userData.classificationResult,
|
||||||
|
testId = userData._id,
|
||||||
|
testTime = userData.testTime,
|
||||||
|
collectionTime = userData.testTime,
|
||||||
|
expiryTime = userData.testTime,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isTokenAvailable) {
|
||||||
|
hemoCubeViewModel.uploadResult(resultList)
|
||||||
|
}
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { kitDataList ->
|
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { kitDataList ->
|
||||||
kitDataList.forEach { userData ->
|
kitDataList.forEach { userData ->
|
||||||
if (!userData.localFlag) {
|
if (!userData.localFlag) {
|
||||||
@@ -812,37 +734,6 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
|
||||||
val resultList = MolbioV2ResultRequest(mutableListOf(MolbioV2Result()))
|
|
||||||
userDataList.forEach { userData ->
|
|
||||||
if (!userData.molbioFlag && isTokenAvailable) {
|
|
||||||
resultList.results?.add(
|
|
||||||
MolbioV2Result(
|
|
||||||
rawData = userData,
|
|
||||||
analysisId = userData._id,
|
|
||||||
analysisDate = "2024-02-08 16:33:56",//userData.testTime,
|
|
||||||
analysisStatus = userData.classificationResult,
|
|
||||||
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(),
|
|
||||||
interpretation = userData.classificationResult,
|
|
||||||
testId = userData._id,
|
|
||||||
testTime = "2024-02-08 16:33:56",//userData.testTime,
|
|
||||||
collectionTime = "2024-02-08 16:33:56",//userData.testTime,
|
|
||||||
expiryTime = "2024-02-08 16:33:56"//userData.testTime,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
userData.molbioFlag = true
|
|
||||||
hemoCubeViewModel.uploadResult(resultList)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!userData.localFlag) {
|
|
||||||
userData.localFlag = true
|
|
||||||
hemoCubeViewModel.bulkAddResultTestToDb(userData)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun downloadLocalDBData(dialog: DialogInterface) {
|
// private fun downloadLocalDBData(dialog: DialogInterface) {
|
||||||
@@ -962,44 +853,4 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private fun getDeviceId() {
|
|
||||||
val handler = activity as? DeviceCommunicationHandler
|
|
||||||
handler?.sendAndListenToDevice(
|
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
|
||||||
object : UsbServiceListener {
|
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
|
||||||
data?.let {
|
|
||||||
val receivedData = String(it, Charset.forName("UTF-8"))
|
|
||||||
// Assuming the device ID is the full content of the received data. Adjust if needed.
|
|
||||||
deviceId =
|
|
||||||
extractDeviceId(receivedData) // Implement this method based on your data format.
|
|
||||||
if (deviceId.isNotEmpty()) {
|
|
||||||
// Store the deviceId in SharedPreferences
|
|
||||||
with(sharedPreference.edit()) {
|
|
||||||
putString(Constants.DEVICE_ID, deviceId)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
// Optionally, you can update UI or proceed with further logic now that you have the device ID
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
// Update your UI or trigger next steps here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
|
||||||
// Handle USB communication error
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fun extractDeviceId(receivedData: String): String {
|
|
||||||
// Example based on the format "SNS HPP1-3038 SNE"
|
|
||||||
val regex = "SNS (\\w+) SNE".toRegex()
|
|
||||||
val matchResult = regex.find(receivedData)
|
|
||||||
return matchResult?.groups?.get(1)?.value ?: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -22,11 +22,8 @@ import androidx.activity.viewModels
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.api.DeviceCommunicationHandler
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.UsbServiceListener
|
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
@@ -36,7 +33,7 @@ import `in`.sminnovations.hpostesting.databinding.ActivityDeviceBinding
|
|||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DeviceActivity : AppCompatActivity(), DeviceCommunicationHandler {
|
class DeviceActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityDeviceBinding
|
private lateinit var binding: ActivityDeviceBinding
|
||||||
private val deviceViewModel by viewModels<DeviceViewModel>()
|
private val deviceViewModel by viewModels<DeviceViewModel>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
@@ -180,8 +177,4 @@ class DeviceActivity : AppCompatActivity(), DeviceCommunicationHandler {
|
|||||||
deviceViewModel.isServiceConnected = false
|
deviceViewModel.isServiceConnected = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener) {
|
|
||||||
mService.sendAndListenToHemoCube(command = HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND, listener)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,6 @@ class DeviceViewModel @Inject constructor(
|
|||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
// val networkStatusLiveData: LiveData<Boolean>
|
// val networkStatusLiveData: LiveData<Boolean>
|
||||||
// get() = _networkStatusLiveData
|
// get() = _networkStatusLiveData
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
val fireBaseBulkUpload = MutableLiveData<String>()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -21,11 +21,8 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.api.DeviceCommunicationHandler
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.UsbServiceListener
|
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
@@ -34,7 +31,7 @@ import `in`.sminnovations.hpostesting.R
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityAutoDacBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityAutoDacBinding
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DeviceProvisionActivity : AppCompatActivity(), DeviceCommunicationHandler {
|
class DeviceProvisionActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityAutoDacBinding
|
private lateinit var binding: ActivityAutoDacBinding
|
||||||
val viewModel: DeviceProvisionViewModel by viewModels()
|
val viewModel: DeviceProvisionViewModel by viewModels()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
@@ -183,8 +180,4 @@ class DeviceProvisionActivity : AppCompatActivity(), DeviceCommunicationHandler
|
|||||||
viewModel.isServiceConnected = false
|
viewModel.isServiceConnected = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener) {
|
|
||||||
mService.sendAndListenToHemoCube(command = HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND, listener)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,12 +11,10 @@ import android.view.ViewGroup
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import com.example.hpostesting.data.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
|
||||||
import com.example.hpostesting.presentation.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
@@ -24,14 +22,11 @@ import com.google.firebase.ktx.Firebase
|
|||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
||||||
|
|
||||||
class DeviceProvisionFragment : Fragment() {
|
class DeviceProvisionFragment : Fragment() {
|
||||||
|
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
private lateinit var binding: FragmentDeviceProvisionBinding
|
private lateinit var binding: FragmentDeviceProvisionBinding
|
||||||
private val viewModel: DeviceProvisionViewModel by activityViewModels()
|
private val viewModel: DeviceProvisionViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private lateinit var deviceProvisionResponse: String
|
|
||||||
private var currentDeviceData: DeviceData? = null
|
|
||||||
private var isOnline = false
|
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
@@ -39,11 +34,13 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initViews()
|
initViews()
|
||||||
observeViewModel()
|
observeViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
listenToHemoCube()
|
listenToHemoCube()
|
||||||
getDeviceId()
|
getDeviceId()
|
||||||
@@ -59,11 +56,7 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun observeViewModel() {
|
private fun observeViewModel() {
|
||||||
viewModel.deviceData.observe(viewLifecycleOwner) {
|
|
||||||
currentDeviceData = it
|
|
||||||
}
|
|
||||||
|
|
||||||
viewModel.deviceProvisionResponse.observe(viewLifecycleOwner) { response ->
|
viewModel.deviceProvisionResponse.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
@@ -93,33 +86,14 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
)
|
)
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
startActivity(
|
startActivity(Intent(requireContext(), DashboardActivity::class.java))
|
||||||
Intent(
|
|
||||||
requireContext(),
|
|
||||||
DashboardActivity::class.java
|
|
||||||
)
|
|
||||||
)
|
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity, "Device registered successfully", Toast.LENGTH_LONG
|
activity, "Device registered successfully", Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
viewModel.addDeviceProvisionDataToDb(
|
|
||||||
DeviceData(
|
|
||||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
|
||||||
username = response.data.data?.credentials?.username.toString(),
|
|
||||||
password = response.data.data?.credentials?.password.toString(),
|
|
||||||
deviceProvisionResponse = response.data.data.toString(),
|
|
||||||
natsToken = response.data.data?.device?.deviceUser?.natsToken.toString(),
|
|
||||||
natsTokenExpiry = response.data.data?.device?.deviceUser?.natsTokenExpiry.toString()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()))
|
|
||||||
Log.e("idpass",response.toString())
|
|
||||||
Log.e("idpass",response.data.data?.credentials?.username.toString())
|
|
||||||
Log.e("idpass",deviceProvisionResponse)
|
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
"An error in device provision: ${response.data.message}",
|
"An error occurred in device provision: ${response.data.message}",
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
@@ -144,13 +118,6 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
|
||||||
if (result == "Success") {
|
|
||||||
Toast.makeText(
|
|
||||||
activity, "Device provision successfully uploaded to firebase", Toast.LENGTH_LONG
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDeviceId() {
|
private fun getDeviceId() {
|
||||||
@@ -167,8 +134,7 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
val fullReadOutput = StringBuilder()
|
val fullReadOutput = StringBuilder()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(activity as DeviceProvisionActivity).mService.listenToHemoCube(object :
|
(activity as DeviceProvisionActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||||
UsbServiceListener {
|
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.hpostesting.data.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.model.Response
|
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -15,54 +13,17 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class DeviceProvisionViewModel @Inject constructor(
|
class DeviceProvisionViewModel @Inject constructor(
|
||||||
private val repository: Repository,
|
private val databaseRepository: Repository
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
|
|
||||||
val deviceProvisionResponse = MutableLiveData<Result<DeviceProvisionResponse>>()
|
val deviceProvisionResponse = MutableLiveData<Result<DeviceProvisionResponse>>()
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
|
||||||
val fireBaseBulkUpload = MutableLiveData<String>()
|
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
|
||||||
|
|
||||||
fun deviceProvision(deviceProvisionRequest: DeviceProvisionRequest) = viewModelScope.launch {
|
fun deviceProvision(deviceProvisionRequest: DeviceProvisionRequest) = viewModelScope.launch {
|
||||||
deviceProvisionResponse.postValue(Result.Loading())
|
deviceProvisionResponse.postValue(Result.Loading())
|
||||||
repository.deviceProvision(deviceProvisionRequest).let {
|
databaseRepository.deviceProvision(deviceProvisionRequest).let {
|
||||||
deviceProvisionResponse.postValue(it)
|
deviceProvisionResponse.postValue(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun addDeviceId(data: DeviceData) {
|
|
||||||
viewModelScope.launch {
|
|
||||||
try {
|
|
||||||
repository.uploadDeviceId(data)
|
|
||||||
fireBaseUpload.postValue("Successfully device Id uploaded to firebase")
|
|
||||||
} catch (e: Exception) {
|
|
||||||
// Log.e("Testdb", "Exception during data upload: ${e.message}")
|
|
||||||
fireBaseUpload.postValue("Error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addDeviceProvisionDataToDb(data: DeviceData) {
|
|
||||||
viewModelScope.launch {
|
|
||||||
try {
|
|
||||||
when (val response = repository.getDeviceResponse(data)) {
|
|
||||||
is Response.Success -> {
|
|
||||||
// Log.i("Testdb", "Data uploaded to Firestore successfully")
|
|
||||||
fireBaseUpload.postValue("Successfully device response uploaded to firebase")
|
|
||||||
}
|
|
||||||
|
|
||||||
is Response.Error -> {
|
|
||||||
// Log.e("Testdb", "Error uploading data to Firestore: $response")
|
|
||||||
fireBaseUpload.postValue("Error")
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {}
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
// Log.e("Testdb", "Exception during data upload: ${e.message}")
|
|
||||||
fireBaseUpload.postValue("Error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -142,6 +142,9 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun checkUpdate(checkUpdateRequest: CheckUpdateRequest) = viewModelScope.launch {
|
fun checkUpdate(checkUpdateRequest: CheckUpdateRequest) = viewModelScope.launch {
|
||||||
checkUpdate.postValue(Result.Loading())
|
checkUpdate.postValue(Result.Loading())
|
||||||
repository.checkUpdate(checkUpdateRequest).let {
|
repository.checkUpdate(checkUpdateRequest).let {
|
||||||
@@ -156,6 +159,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun downloadClientCertificate() = viewModelScope.launch {
|
fun downloadClientCertificate() = viewModelScope.launch {
|
||||||
downloadcertificate.postValue(Result.Loading())
|
downloadcertificate.postValue(Result.Loading())
|
||||||
repository.downloadClientCertificate().let {
|
repository.downloadClientCertificate().let {
|
||||||
@@ -163,6 +167,9 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun startPeriodicCheckUpdate() {
|
fun startPeriodicCheckUpdate() {
|
||||||
val periodicRequest = PeriodicWorkRequestBuilder<CheckUpdateWorker>(
|
val periodicRequest = PeriodicWorkRequestBuilder<CheckUpdateWorker>(
|
||||||
repeatInterval = 1, repeatIntervalTimeUnit = TimeUnit.MINUTES
|
repeatInterval = 1, repeatIntervalTimeUnit = TimeUnit.MINUTES
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ import android.content.ServiceConnection
|
|||||||
import android.hardware.usb.UsbDevice
|
import android.hardware.usb.UsbDevice
|
||||||
import android.hardware.usb.UsbDeviceConnection
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
import android.hardware.usb.UsbManager
|
import android.hardware.usb.UsbManager
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
@@ -43,6 +45,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
private val TAG = "HemoCube"
|
private val TAG = "HemoCube"
|
||||||
|
|
||||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||||
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
@@ -81,6 +84,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
||||||
@@ -105,6 +109,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
open fun connectUsb(permissionGranted: Boolean) {
|
open fun connectUsb(permissionGranted: Boolean) {
|
||||||
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||||
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
@@ -125,32 +130,40 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("MutableImplicitPendingIntent")
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
|
@SuppressLint("UnspecifiedImmutableFlag")
|
||||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
val mPendingIntent: PendingIntent
|
val mPendingIntent: PendingIntent
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
val pendingIntentFlags = when {
|
||||||
mPendingIntent = PendingIntent.getBroadcast(
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
PendingIntent.FLAG_IMMUTABLE
|
||||||
)
|
}
|
||||||
} else {
|
else -> {
|
||||||
mPendingIntent = PendingIntent.getBroadcast(
|
|
||||||
this,
|
|
||||||
0,
|
|
||||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
|
||||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||||
|
pendingIntentFlags
|
||||||
|
)
|
||||||
|
|
||||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||||
registerReceiver(broadcastReceiver, filter)
|
registerReceiver(broadcastReceiver, filter, RECEIVER_EXPORTED)
|
||||||
|
|
||||||
|
// Request permission
|
||||||
manager.requestPermission(device, mPendingIntent)
|
manager.requestPermission(device, mPendingIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setupService() {
|
fun setupService() {
|
||||||
val intent = Intent(this, UsbService::class.java)
|
val intent = Intent(this, UsbService::class.java)
|
||||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
open fun reconnectDevice() {
|
open fun reconnectDevice() {
|
||||||
mService.disconnect()
|
mService.disconnect()
|
||||||
unbindService(connection)
|
unbindService(connection)
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true">
|
tools:context="com.example.hpostesting.presentation.dashboard.GalleryFragment">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:context="com.example.hpostesting.presentation.dashboard.GalleryFragment">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_subtitle4"
|
android:id="@+id/tv_subtitle4"
|
||||||
@@ -84,6 +79,20 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_auto_dac" />
|
app:layout_constraintTop_toBottomOf="@id/btn_auto_dac" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn_deviceProvision"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="@string/deviceProvision"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_deviceInfo" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_deviceInfo"
|
android:id="@+id/btn_deviceInfo"
|
||||||
@@ -99,20 +108,6 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_calibration" />
|
app:layout_constraintTop_toBottomOf="@id/btn_calibration" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btn_deviceProvision"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="visible"
|
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:clickable="false"
|
|
||||||
android:text="@string/deviceProvision"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:cornerRadius="16dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_deviceInfo" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_firefox"
|
android:id="@+id/btn_firefox"
|
||||||
@@ -142,5 +137,4 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_firefox" />
|
app:layout_constraintTop_toBottomOf="@id/btn_firefox" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</ScrollView>
|
|
||||||
@@ -115,15 +115,15 @@
|
|||||||
tools:listitem="@layout/offline_user_list_view" />
|
tools:listitem="@layout/offline_user_list_view" />
|
||||||
|
|
||||||
|
|
||||||
<!-- <ImageView-->
|
<ImageView
|
||||||
<!-- android:id="@+id/btnSaveLocal"-->
|
android:id="@+id/btnSaveLocal"
|
||||||
<!-- android:layout_width="30dp"-->
|
android:layout_width="30dp"
|
||||||
<!-- android:layout_height="30dp"-->
|
android:layout_height="30dp"
|
||||||
<!-- android:layout_marginEnd="10dp"-->
|
android:layout_marginEnd="10dp"
|
||||||
<!-- android:src="@drawable/downloads"-->
|
android:src="@drawable/downloads"
|
||||||
<!-- android:visibility="gone"-->
|
android:visibility="gone"
|
||||||
<!-- app:layout_constraintBottom_toBottomOf="@+id/rv_order_offline"-->
|
app:layout_constraintBottom_toBottomOf="@+id/rv_order_offline"
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,6 @@
|
|||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||||
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:id="@+id/cardView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:cardCornerRadius="16dp">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageView"
|
android:id="@+id/imageView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -25,7 +19,6 @@
|
|||||||
android:contentDescription="@string/nav_header_desc"
|
android:contentDescription="@string/nav_header_desc"
|
||||||
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
android:paddingTop="@dimen/nav_header_vertical_spacing"
|
||||||
app:srcCompat="@mipmap/hpos_icon" />
|
app:srcCompat="@mipmap/hpos_icon" />
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
Reference in New Issue
Block a user