Merge branch 'dev' into 'dev-check-apk-update'
# Conflicts: # app/build.gradle # app/src/main/java/com/example/hpostesting/presentation/dashboard/DashboardActivity.kt # app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt # app/src/main/java/com/example/hpostesting/presentation/hemocube/HemocubeActivity.kt # build.gradle # gradle/wrapper/gradle-wrapper.properties
This commit is contained in:
3
.idea/gradle.xml
generated
3
.idea/gradle.xml
generated
@@ -4,9 +4,8 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId "in.sminnovations.hpostesting.dev"
|
applicationId "in.sminnovations.hpostesting.dev"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 120
|
versionCode 114
|
||||||
versionName "2.1.120"
|
versionName "2.1.114"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,7 @@
|
|||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:stateNotNeeded="true"
|
android:stateNotNeeded="true"
|
||||||
tools:replace="android:screenOrientation" />
|
tools:replace="android:screenOrientation" />
|
||||||
|
<!-- ${applicationId}-->
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.fileprovider"
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ object Constants {
|
|||||||
const val HEMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
const val HEMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
||||||
|
|
||||||
const val BASE_URL = "www.google.com"
|
const val BASE_URL = "www.google.com"
|
||||||
|
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
||||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||||
|
|
||||||
const val MOLBIO_INTEGRATION = true
|
const val MOLBIO_INTEGRATION = true
|
||||||
|
|||||||
@@ -29,4 +29,8 @@ interface HemoCubeDao {
|
|||||||
|
|
||||||
@Query("UPDATE hemo_cube_test_table SET isCSVCreated = :newValue WHERE _id = :id")
|
@Query("UPDATE hemo_cube_test_table SET isCSVCreated = :newValue WHERE _id = :id")
|
||||||
suspend fun updateCSVFieldById(id: String, newValue: Boolean)
|
suspend fun updateCSVFieldById(id: String, newValue: Boolean)
|
||||||
|
|
||||||
|
@Query("SELECT * from hemo_cube_test_table WHERE molbioFlag = :status")
|
||||||
|
suspend fun getPendingUser(status: Boolean): List<HemoCubeTestData>
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ import com.example.hpostesting.data.model.patient.UserData
|
|||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class],
|
entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class],
|
||||||
version = 27,
|
version = 28,
|
||||||
exportSchema = false
|
exportSchema = false
|
||||||
)
|
)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
|
|||||||
@@ -26,4 +26,14 @@ data class DeviceData(
|
|||||||
var natsToken: String = "",
|
var natsToken: String = "",
|
||||||
@get:PropertyName("natsTokenExpiry") @set:PropertyName("natsTokenExpiry")
|
@get:PropertyName("natsTokenExpiry") @set:PropertyName("natsTokenExpiry")
|
||||||
var natsTokenExpiry: String = "",
|
var natsTokenExpiry: String = "",
|
||||||
|
@get:PropertyName("deviceUpdateAvailable") @set:PropertyName("deviceUpdateAvailable")
|
||||||
|
var deviceUpdateAvailable: Boolean = false,
|
||||||
|
@get:PropertyName("updatePath") @set:PropertyName("updatePath")
|
||||||
|
var updatePath: String = "",
|
||||||
|
@get:PropertyName("deviceVersion") @set:PropertyName("deviceVersion")
|
||||||
|
var deviceVersion: String = "",
|
||||||
|
@get:PropertyName("globalUpdateDone") @set:PropertyName("globalUpdateDone")
|
||||||
|
var globalUpdateDone: Boolean = false,
|
||||||
|
@get:PropertyName("globalUpdateIgnore") @set:PropertyName("globalUpdateIgnore")
|
||||||
|
var globalUpdateIgnore: Boolean = false,
|
||||||
)
|
)
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.example.hpostesting.di
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
|
||||||
import com.example.hpostesting.data.dao.UserDao
|
|
||||||
import com.example.hpostesting.domain.SaveRawData
|
|
||||||
import com.example.hpostesting.domain.SaveRawDataTest
|
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.Provides
|
|
||||||
import dagger.hilt.InstallIn
|
|
||||||
import dagger.hilt.android.components.ViewModelComponent
|
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
||||||
|
|
||||||
@Module
|
|
||||||
@InstallIn(ViewModelComponent::class)
|
|
||||||
object ViewModelModule {
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
fun provideTestRightViewModel(
|
|
||||||
saveRawData: SaveRawData,
|
|
||||||
saveRawDataTest: SaveRawDataTest,
|
|
||||||
databaseRepository: DatabaseRepository,
|
|
||||||
userDao: UserDao,
|
|
||||||
context: Context
|
|
||||||
): TestRightViewModel {
|
|
||||||
return TestRightViewModel(saveRawData, saveRawDataTest, databaseRepository, userDao, context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,6 +22,8 @@ import com.example.hpostesting.domain.LogFileManager
|
|||||||
import com.example.hpostesting.domain.LogFileManagerImpl
|
import com.example.hpostesting.domain.LogFileManagerImpl
|
||||||
import com.example.hpostesting.domain.SaveRawData
|
import com.example.hpostesting.domain.SaveRawData
|
||||||
import com.example.hpostesting.domain.SaveRawDataTest
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
|
import com.example.hpostesting.presentation.UsbServiceListenerImpl
|
||||||
import com.example.hpostesting.util.PropertyProviderImpl
|
import com.example.hpostesting.util.PropertyProviderImpl
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
@@ -179,4 +181,10 @@ object AppModule {
|
|||||||
fun provideLocalFileDataSource(): LocalFileDataSource {
|
fun provideLocalFileDataSource(): LocalFileDataSource {
|
||||||
return LocalFileDataSourceImpl()
|
return LocalFileDataSourceImpl()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideUsbServiceListener(context: Context): UsbServiceListener {
|
||||||
|
return UsbServiceListenerImpl(context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -125,13 +125,8 @@ class NatsManager(datacollector: DashboardActivity) {
|
|||||||
|
|
||||||
if (nc?.status == Connection.Status.CONNECTED) {
|
if (nc?.status == Connection.Status.CONNECTED) {
|
||||||
Log.d("NATSCONNECTION", "NATS is successfully connected.")
|
Log.d("NATSCONNECTION", "NATS is successfully connected.")
|
||||||
|
|
||||||
val d = nc?.createDispatcher { msg: Message? ->
|
|
||||||
println("Nats dispatcher $msg")
|
|
||||||
}
|
|
||||||
|
|
||||||
nc?.subscribe("device.hpos.${deviceId}.ping")
|
nc?.subscribe("device.hpos.${deviceId}.ping")
|
||||||
|
// Log.d(TAG, "Nats subscribed with ping-"+d)
|
||||||
nc?.publish(
|
nc?.publish(
|
||||||
"server.hpos.${deviceId}.ping",
|
"server.hpos.${deviceId}.ping",
|
||||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
||||||
@@ -140,7 +135,10 @@ class NatsManager(datacollector: DashboardActivity) {
|
|||||||
"server.hpos.${deviceId}.health",
|
"server.hpos.${deviceId}.health",
|
||||||
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
"ALIVE".toByteArray(StandardCharsets.UTF_8)
|
||||||
)
|
)
|
||||||
|
val d = nc?.createDispatcher { msg: Message? ->
|
||||||
|
println("Nats dispatcher $msg")
|
||||||
|
Log.d(TAG, "Nats dispatcher--$msg")
|
||||||
|
}
|
||||||
d?.subscribe("device.hpos.${deviceId}.ping") { msg ->
|
d?.subscribe("device.hpos.${deviceId}.ping") { msg ->
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||||
datacollector.setResponse(response)
|
datacollector.setResponse(response)
|
||||||
@@ -175,7 +173,8 @@ class NatsManager(datacollector: DashboardActivity) {
|
|||||||
d?.subscribe("device.hpos.${deviceId}.checkUpdate") { msg ->
|
d?.subscribe("device.hpos.${deviceId}.checkUpdate") { msg ->
|
||||||
val response = String(msg.data, StandardCharsets.UTF_8)
|
val response = String(msg.data, StandardCharsets.UTF_8)
|
||||||
datacollector.setResponse(response)
|
datacollector.setResponse(response)
|
||||||
println("Message received (up to 100 times): $response")
|
println("Message received (up to 100 times) on topic checkupdate: $response")
|
||||||
|
Log.d(TAG, "subscribed msg ${msg} on topic checkupdate")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d("NATSCONNECTION", "NATS is not connected. Current status: ${nc?.status}")
|
Log.d("NATSCONNECTION", "NATS is not connected. Current status: ${nc?.status}")
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.Toast
|
||||||
|
|
||||||
|
class UsbServiceListenerImpl(private val context: Context): UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
if (data != null) {
|
||||||
|
val receivedData = String(data)
|
||||||
|
logData(receivedData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
showToast("USB Error: ${e?.message}")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showToast(message: String) {
|
||||||
|
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun logData(data: String) {
|
||||||
|
Log.d("UsbServiceListener", "Received data from USB: $data")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.example.hpostesting.presentation.dashboard
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@@ -30,6 +31,8 @@ import com.google.android.material.navigation.NavigationView
|
|||||||
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
||||||
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.BuildConfig
|
import `in`.sminnovations.hpostesting.BuildConfig
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
@@ -55,6 +58,7 @@ open interface IDataCollector: NatsMessageCallback {
|
|||||||
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||||
|
|
||||||
val TAG = "DashboardActivity"
|
val TAG = "DashboardActivity"
|
||||||
|
private var isRegistered = false
|
||||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||||
private lateinit var binding: ActivityDashboardBinding
|
private lateinit var binding: ActivityDashboardBinding
|
||||||
lateinit var sharedPreferences: SharedPreferences
|
lateinit var sharedPreferences: SharedPreferences
|
||||||
@@ -72,6 +76,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
|
|
||||||
override fun onMessageReceived(topic: String, message: String) {
|
override fun onMessageReceived(topic: String, message: String) {
|
||||||
// Handle incoming messages from NATS
|
// Handle incoming messages from NATS
|
||||||
|
|
||||||
Log.d(TAG, "Received message on topic $topic: $message")
|
Log.d(TAG, "Received message on topic $topic: $message")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +135,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val drawerLayout: DrawerLayout = binding.drawerLayout
|
val drawerLayout: DrawerLayout = binding.drawerLayout
|
||||||
val navView: NavigationView = binding.navView
|
val navView: NavigationView = binding.navView
|
||||||
val navController = findNavController(R.id.nav_host_fragment_content_dashboard)
|
val navController = findNavController(R.id.nav_host_fragment_content_dashboard)
|
||||||
@@ -148,6 +154,8 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
menuInflater.inflate(R.menu.dashboard, menu)
|
menuInflater.inflate(R.menu.dashboard, menu)
|
||||||
@@ -183,6 +191,13 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
if(isRegistered) {
|
||||||
|
try {
|
||||||
|
unregisterReceiver(downloadReceiver)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.d("HomeFragment", e.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +248,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun setResponse(response: String) {
|
override fun setResponse(response: String) {
|
||||||
|
|
||||||
responses = responses+response+"\n"
|
responses = responses+response+"\n"
|
||||||
println(responses)
|
println(responses)
|
||||||
// if (response.contains("checkUpdate")) {
|
// if (response.contains("checkUpdate")) {
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import android.app.DownloadManager
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Context.BATTERY_SERVICE
|
import android.content.Context.BATTERY_SERVICE
|
||||||
|
import android.content.Context.RECEIVER_EXPORTED
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.net.Uri
|
||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -49,6 +55,7 @@ import com.google.firebase.perf.ktx.performance
|
|||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||||
|
import kotlinx.coroutines.tasks.await
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.io.BufferedOutputStream
|
import java.io.BufferedOutputStream
|
||||||
@@ -65,6 +72,8 @@ import java.util.zip.ZipInputStream
|
|||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class HomeFragment : Fragment() {
|
class HomeFragment : Fragment() {
|
||||||
|
private var isRegistered = false
|
||||||
|
private var downloadId: Long = 0
|
||||||
private lateinit var binding: FragmentHomeBinding
|
private lateinit var binding: FragmentHomeBinding
|
||||||
private val viewModel: TestRightViewModel by activityViewModels()
|
private val viewModel: TestRightViewModel by activityViewModels()
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
@@ -98,8 +107,10 @@ class HomeFragment : Fragment() {
|
|||||||
binding.labelQuickCapture.visibility = View.VISIBLE
|
binding.labelQuickCapture.visibility = View.VISIBLE
|
||||||
binding.btnQuickCapture.visibility = View.VISIBLE
|
binding.btnQuickCapture.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeviceId()
|
getDeviceId()
|
||||||
checkUnprocessedCSVData()
|
checkUnprocessedCSVData()
|
||||||
|
checkForUpdate()
|
||||||
viewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
viewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
deleteIncompleteRegistrations(userData)
|
deleteIncompleteRegistrations(userData)
|
||||||
}
|
}
|
||||||
@@ -1088,6 +1099,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getDeviceId() {
|
private fun getDeviceId() {
|
||||||
|
Log.d("HomeFragmentUSb","getDeviceId")
|
||||||
val handler = activity as? DeviceCommunicationHandler
|
val handler = activity as? DeviceCommunicationHandler
|
||||||
handler?.sendAndListenToDevice(
|
handler?.sendAndListenToDevice(
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
@@ -1095,9 +1107,9 @@ class HomeFragment : Fragment() {
|
|||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val receivedData = String(it, Charset.forName("UTF-8"))
|
val receivedData = String(it, Charset.forName("UTF-8"))
|
||||||
|
Log.d("HomeFragment","USB data"+receivedData)
|
||||||
// Assuming the device ID is the full content of the received data. Adjust if needed.
|
// Assuming the device ID is the full content of the received data. Adjust if needed.
|
||||||
deviceId =
|
deviceId = extractDeviceId(receivedData) // Implement this method based on your data format.
|
||||||
extractDeviceId(receivedData) // Implement this method based on your data format.
|
|
||||||
if (deviceId.isNotEmpty()) {
|
if (deviceId.isNotEmpty()) {
|
||||||
// Store the deviceId in SharedPreferences
|
// Store the deviceId in SharedPreferences
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
@@ -1114,6 +1126,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
// Handle USB communication error
|
// Handle USB communication error
|
||||||
|
Log.d("HomeFragment","USB read error"+e.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -1125,5 +1138,168 @@ class HomeFragment : Fragment() {
|
|||||||
val matchResult = regex.find(receivedData)
|
val matchResult = regex.find(receivedData)
|
||||||
return matchResult?.groups?.get(1)?.value ?: ""
|
return matchResult?.groups?.get(1)?.value ?: ""
|
||||||
}
|
}
|
||||||
|
@SuppressLint("SuspiciousIndentation")
|
||||||
|
private fun checkForUpdate() {
|
||||||
|
try {
|
||||||
|
val db = Firebase.firestore
|
||||||
|
//val deviceId = deviceId
|
||||||
|
|
||||||
|
val deviceRef = db.collection("deviceUpdate").document(Constants.DOCUMENT_ID_FOR_UPDATE)
|
||||||
|
|
||||||
|
deviceRef.get().addOnSuccessListener { documentSnapshot ->
|
||||||
|
if (documentSnapshot.exists()) {
|
||||||
|
|
||||||
|
val deviceData =
|
||||||
|
documentSnapshot.toObject(DeviceData::class.java)
|
||||||
|
|
||||||
|
// deviceData?.let { data ->
|
||||||
|
|
||||||
|
val deviceVersion = deviceData!!.deviceVersion
|
||||||
|
val deviceUpdateAvailableGlobal= deviceData.deviceUpdateAvailable
|
||||||
|
val updatePathGlobal= deviceData.updatePath
|
||||||
|
|
||||||
|
// if(deviceUpdateAvailableGlobal){
|
||||||
|
db.collection("devices").whereEqualTo("deviceId", deviceId).get().addOnSuccessListener { documentSnapshotNew ->
|
||||||
|
if (documentSnapshotNew.documents.isNotEmpty()) {
|
||||||
|
documentSnapshotNew.documents.forEach{
|
||||||
|
val documentIn = it.toObject(DeviceData::class.java)
|
||||||
|
|
||||||
|
val globalUpdateIgnore = documentIn!!.globalUpdateIgnore
|
||||||
|
val deviceUpdateAvailable = documentIn.deviceUpdateAvailable
|
||||||
|
val globalUpdateDone = documentIn.globalUpdateDone
|
||||||
|
val updatePath = documentIn.updatePath
|
||||||
|
if(globalUpdateIgnore){
|
||||||
|
if(deviceUpdateAvailable){
|
||||||
|
val update = db.collection("devices").document(it.id).update("deviceUpdateAvailable",false)
|
||||||
|
update.addOnSuccessListener {
|
||||||
|
Log.d("HomeFragmentUpdate","Device local update done")
|
||||||
|
|
||||||
|
initiateUpdate(updatePath)
|
||||||
|
}.addOnFailureListener{
|
||||||
|
Log.e("fetchDeviceUpdate", "update fail.")
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Log.d("HomeFragmentUpdate","Device update not available")
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(!globalUpdateDone){
|
||||||
|
val update = db.collection("devices").document(it.id).update("globalUpdateDone",true)
|
||||||
|
update.addOnSuccessListener {
|
||||||
|
Log.d("HomeFragmentUpdate","Device global update done")
|
||||||
|
|
||||||
|
initiateUpdate(updatePathGlobal)
|
||||||
|
}.addOnFailureListener{
|
||||||
|
Log.e("fetchDeviceUpdate", "update fail.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.e("fetchDeviceUpdate", "Document does not exist.")
|
||||||
|
}
|
||||||
|
}.addOnFailureListener { exception ->
|
||||||
|
Log.e("fetchDeviceUpdate", "Error fetching device data", exception)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Toast.makeText(requireActivity()," true -version."+deviceVersion+"updatePath.."+updatePath,Toast.LENGTH_LONG).show()
|
||||||
|
|
||||||
|
|
||||||
|
// Log for debugging
|
||||||
|
Log.d(
|
||||||
|
"fetchDeviceCredentials",
|
||||||
|
"deviceVersion: $deviceVersion, Password: $deviceUpdateAvailableGlobal, updatePath: $updatePathGlobal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// } ?: Log.e("fetchDeviceUpdate", "Failed to parse device data.")
|
||||||
|
} else {
|
||||||
|
Log.e("fetchDeviceUpdate", "Document does not exist.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.addOnFailureListener { exception ->
|
||||||
|
Log.e("fetchDeviceUpdate", "Error fetching device data", exception)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("fetchDeviceUpdate", "Error in fetchDeviceUpdate", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun initiateUpdate(url: String) {
|
||||||
|
val apkUrl = url
|
||||||
|
if (!isValidHttpUrl(apkUrl)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val request = DownloadManager.Request(Uri.parse(apkUrl))
|
||||||
|
request.setTitle("App Update")
|
||||||
|
request.setDescription("Downloading update...")
|
||||||
|
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||||
|
request.setDestinationInExternalFilesDir(requireActivity(), "Updates", "update.apk")
|
||||||
|
|
||||||
|
val downloadManager = requireActivity().getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||||
|
downloadId = downloadManager.enqueue(request)
|
||||||
|
|
||||||
|
// Register a BroadcastReceiver to receive the download complete event
|
||||||
|
val filter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
isRegistered = true
|
||||||
|
requireActivity().registerReceiver(downloadReceiver, filter, RECEIVER_EXPORTED)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private fun extractApkUrl(responseBody: ResponseBody): String {
|
||||||
|
return responseBody.string()
|
||||||
|
}
|
||||||
|
private fun isValidHttpUrl(url: String): Boolean {
|
||||||
|
return url.startsWith("http://") || url.startsWith("https://")
|
||||||
|
}
|
||||||
|
private val downloadReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
val id = intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
||||||
|
if (id == downloadId) {
|
||||||
|
installApk()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun installApk() {
|
||||||
|
val file = File(requireActivity().getExternalFilesDir("Updates"), "update.apk")
|
||||||
|
file.setReadable(true, false) // Ensure the file is readable
|
||||||
|
|
||||||
|
val pInfo = requireActivity().baseContext.packageManager.getPackageInfo(requireActivity().baseContext.packageName, 0)
|
||||||
|
Log.d("HomeFragmentShowInfo",pInfo.packageName.toString())
|
||||||
|
val uri: Uri = FileProvider.getUriForFile(
|
||||||
|
requireActivity(),
|
||||||
|
"${pInfo.packageName}.fileprovider",
|
||||||
|
file
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create an intent to install the APK
|
||||||
|
val installIntent = Intent(Intent.ACTION_INSTALL_PACKAGE)
|
||||||
|
installIntent.data = uri
|
||||||
|
installIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
||||||
|
Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||||
|
Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
|
installIntent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
|
||||||
|
|
||||||
|
// Start the installation
|
||||||
|
startActivity(installIntent)
|
||||||
|
|
||||||
|
Log.d("InstallApk", "Install Intent URI: $uri")
|
||||||
|
Log.d("InstallApk", "Package Name: ${requireActivity().packageName}")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
if(isRegistered) {
|
||||||
|
try {
|
||||||
|
requireActivity().unregisterReceiver(downloadReceiver)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.d("HomeFragment", e.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.onDestroy()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,10 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
password = response.data.data?.credentials?.password.toString(),
|
password = response.data.data?.credentials?.password.toString(),
|
||||||
deviceProvisionResponse = response.data.data.toString(),
|
deviceProvisionResponse = response.data.data.toString(),
|
||||||
natsToken = response.data.data?.device?.deviceUser?.natsToken.toString(),
|
natsToken = response.data.data?.device?.deviceUser?.natsToken.toString(),
|
||||||
natsTokenExpiry = response.data.data?.device?.deviceUser?.natsTokenExpiry.toString()
|
natsTokenExpiry = response.data.data?.device?.deviceUser?.natsTokenExpiry.toString(),
|
||||||
|
globalUpdateIgnore = false,
|
||||||
|
globalUpdateDone = false,
|
||||||
|
deviceUpdateAvailable = false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()))
|
// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()))
|
||||||
|
|||||||
@@ -590,8 +590,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
led1Gain4 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain4 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain4 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain4 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led3Gain4 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
led3Gain4 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led4Gain4 =
|
led4Gain4 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finishReading()
|
finishReading()
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
|
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
|
val allPendingUserToUpload = MutableLiveData<List<HemoCubeTestData>>()
|
||||||
val allKitTestData = hemoCubeBufferDao.getAll()
|
val allKitTestData = hemoCubeBufferDao.getAll()
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
|
|
||||||
@@ -194,6 +195,9 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun uploadPendingUser() = viewModelScope.launch {
|
||||||
|
allPendingUserToUpload.postValue(hemoCubeDao.getPendingUser(false))
|
||||||
|
}
|
||||||
|
|
||||||
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
||||||
isOnline: Boolean,
|
isOnline: Boolean,
|
||||||
|
|||||||
@@ -148,7 +148,11 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||||
registerReceiver(broadcastReceiver, filter, RECEIVER_EXPORTED)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
registerReceiver(broadcastReceiver, filter, RECEIVER_EXPORTED)
|
||||||
|
}else{
|
||||||
|
registerReceiver(broadcastReceiver, filter)
|
||||||
|
}
|
||||||
manager.requestPermission(device, mPendingIntent)
|
manager.requestPermission(device, mPendingIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,32 +33,53 @@ class UsbService : Service() {
|
|||||||
var bus: UsbServiceListener? = null
|
var bus: UsbServiceListener? = null
|
||||||
|
|
||||||
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
||||||
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
try {
|
||||||
mPort.open(connection)
|
mPort = driver.ports[0]
|
||||||
mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
mPort.open(connection)
|
||||||
isUsbConnected = true
|
|
||||||
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
|
||||||
|
|
||||||
val usbIoManager = SerialInputOutputManager(mPort,
|
if (mPort.device.vendorId == 6790 && mPort.device.productId == 29987)
|
||||||
object : SerialInputOutputManager.Listener {
|
mPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||||
override fun onNewData(data: ByteArray?) {
|
else
|
||||||
listener?.onUsbRead(data)
|
mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||||
}
|
|
||||||
|
|
||||||
override fun onRunError(e: Exception?) {
|
isUsbConnected = true
|
||||||
Log.e(TAG, "onRunError() called inside eventDrivenWrite()")
|
Log.d(TAG, "Usb Connected ${mPort.driver}")
|
||||||
listener?.onUsbError(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
val usbIoManager = SerialInputOutputManager(mPort,
|
||||||
usbIoManager.start();
|
object : SerialInputOutputManager.Listener {
|
||||||
|
override fun onNewData(data: ByteArray?) {
|
||||||
|
listener?.onUsbRead(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRunError(e: Exception?) {
|
||||||
|
Log.e(TAG, "onRunError() called")
|
||||||
|
listener?.onUsbError(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
usbIoManager.start()
|
||||||
|
} catch (ioException: IOException) {
|
||||||
|
Log.e(TAG, "IOException during USB connection: ${ioException.message}", ioException)
|
||||||
|
listener?.onUsbError(ioException)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e(TAG, "Error connecting USB: ${e.message}", e)
|
||||||
|
listener?.onUsbError(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun disconnect() {
|
fun disconnect() {
|
||||||
if (isUsbConnected) {
|
try {
|
||||||
mPort.close()
|
if (isUsbConnected) {
|
||||||
isUsbConnected = false;
|
mPort.close()
|
||||||
Log.d(TAG, "My Usb disconnected:: ${mPort.driver}")
|
isUsbConnected = false
|
||||||
|
Log.d(TAG, "USB Port closed successfully:: ${mPort.driver}")
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "USB Port is not connected")
|
||||||
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Log.e(TAG, "Error closing USB Port: ${e.message}", e)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e(TAG, "An unexpected error occurred: ${e.message}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,4 +17,4 @@
|
|||||||
android:icon="@drawable/baseline_settings_24"
|
android:icon="@drawable/baseline_settings_24"
|
||||||
android:title="@string/menu_settings" />
|
android:title="@string/menu_settings" />
|
||||||
</group>
|
</group>
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
|
||||||
import junit.framework.TestCase
|
|
||||||
import junit.framework.TestCase.assertEquals
|
import junit.framework.TestCase.assertEquals
|
||||||
import junit.framework.TestCase.assertNull
|
import junit.framework.TestCase.assertNull
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
@@ -17,18 +13,9 @@ import org.mockito.MockitoAnnotations
|
|||||||
|
|
||||||
class HemoCubeFragmentTest {
|
class HemoCubeFragmentTest {
|
||||||
|
|
||||||
@Mock
|
|
||||||
lateinit var mockContext: Context
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var mockSharedPreferences: SharedPreferences
|
private lateinit var mockSharedPreferences: SharedPreferences
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var mockActivity: HemocubeActivity // Replace with your actual Activity class
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private lateinit var mockBinding: FragmentHemoCubeReferenceBinding // Replace with your actual Binding class
|
|
||||||
|
|
||||||
private lateinit var hemoCubeFragment: HemoCubeFragment
|
private lateinit var hemoCubeFragment: HemoCubeFragment
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -51,7 +38,7 @@ class HemoCubeFragmentTest {
|
|||||||
val deviceId = hemoCubeFragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
val deviceId = hemoCubeFragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestCase.assertEquals("HPP1-9000", deviceId)
|
assertEquals("HPP1-9000", deviceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -71,7 +58,7 @@ class HemoCubeFragmentTest {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestCase.assertEquals("HPP1-0001", deviceId)
|
assertEquals("HPP1-0001", deviceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -84,8 +71,8 @@ class HemoCubeFragmentTest {
|
|||||||
val result = hemoCubeFragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
val result = hemoCubeFragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
TestCase.assertEquals(true, result)
|
assertEquals(true, result)
|
||||||
TestCase.assertEquals(hemoCubeFragment.allReadingsComplete(0, 1), false)
|
assertEquals(hemoCubeFragment.allReadingsComplete(0, 1), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -381,64 +368,75 @@ class HemoCubeFragmentTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineNormal() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineNormal() {
|
||||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test")
|
val result =
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.5)
|
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.5)
|
||||||
assertEquals("Borderline. Normal", result)
|
assertEquals("Borderline. Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait1() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait1() {
|
||||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test")
|
val result =
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.2)
|
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.2)
|
||||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait2() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait2() {
|
||||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test")
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Positive for Sickle Cell. HPLC for Confirmation", 1.35)
|
0.5,
|
||||||
|
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||||
|
1.35
|
||||||
|
)
|
||||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellDisease() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellDisease() {
|
||||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test")
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Positive for Sickle Cell. HPLC for Confirmation", 1.33)
|
0.5,
|
||||||
|
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||||
|
1.33
|
||||||
|
)
|
||||||
assertEquals("Borderline. Sickle Cell Disease", result)
|
assertEquals("Borderline. Sickle Cell Disease", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_NormalDeviceRatio_ReturnsNormalBelowSlopeRatioThreshold() {
|
fun findResultWithAdditionalMethods_NormalDeviceRatio_ReturnsNormalBelowSlopeRatioThreshold() {
|
||||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 70.0)).thenReturn("Negative Borderline, Repeat Test")
|
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 30.0)
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 30.0)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_NBL_ReturnsNBL() {
|
fun findResultWithAdditionalMethods_NBL_ReturnsNBL() {
|
||||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline, Repeat Test", 70.0)
|
0.5,
|
||||||
|
"Negative Borderline, Repeat Test",
|
||||||
|
70.0
|
||||||
|
)
|
||||||
assertEquals("Negative Borderline, Repeat Test", result)
|
assertEquals("Negative Borderline, Repeat Test", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_SCT_ReturnsSCT() {
|
fun findResultWithAdditionalMethods_SCT_ReturnsSCT() {
|
||||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
val result =
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Trait", 70.0)
|
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Trait", 70.0)
|
||||||
assertEquals("Sickle Cell Trait", result)
|
assertEquals("Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_PBL_ReturnsPBL() {
|
fun findResultWithAdditionalMethods_PBL_ReturnsPBL() {
|
||||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Positive for Sickle Cell. HPLC for Confirmation", 1.35)
|
0.5,
|
||||||
|
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||||
|
1.35
|
||||||
|
)
|
||||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_SCD_ReturnsSCD() {
|
fun findResultWithAdditionalMethods_SCD_ReturnsSCD() {
|
||||||
// `when`(hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Abnormal", 70.0)).thenReturn("Invalid")
|
val result =
|
||||||
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Disease", 70.0)
|
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Disease", 70.0)
|
||||||
assertEquals("Sickle Cell Disease", result)
|
assertEquals("Sickle Cell Disease", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,7 +448,11 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.2
|
val led2Average = 0.2
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioClass, led2Average)
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
|
deviceRatio,
|
||||||
|
deviceRatioClass,
|
||||||
|
led2Average
|
||||||
|
)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("Borderline. Normal", result)
|
assertEquals("Borderline. Normal", result)
|
||||||
@@ -464,7 +466,11 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.14
|
val led2Average = 0.14
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioClass, led2Average)
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
|
deviceRatio,
|
||||||
|
deviceRatioClass,
|
||||||
|
led2Average
|
||||||
|
)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||||
@@ -478,7 +484,11 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.18
|
val led2Average = 0.18
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioClass, led2Average)
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
|
deviceRatio,
|
||||||
|
deviceRatioClass,
|
||||||
|
led2Average
|
||||||
|
)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("Borderline. Sickle Cell Disease", result)
|
assertEquals("Borderline. Sickle Cell Disease", result)
|
||||||
@@ -492,7 +502,11 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.195
|
val led2Average = 0.195
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioClass, led2Average)
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
|
deviceRatio,
|
||||||
|
deviceRatioClass,
|
||||||
|
led2Average
|
||||||
|
)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("Borderline. Sickle Cell Trait", result)
|
assertEquals("Borderline. Sickle Cell Trait", result)
|
||||||
@@ -506,7 +520,11 @@ class HemoCubeFragmentTest {
|
|||||||
val led2Average = 0.189
|
val led2Average = 0.189
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioClass, led2Average)
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
|
deviceRatio,
|
||||||
|
deviceRatioClass,
|
||||||
|
led2Average
|
||||||
|
)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("Borderline. Sickle Cell Disease", result)
|
assertEquals("Borderline. Sickle Cell Disease", result)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ buildscript {
|
|||||||
kotlin_version = '1.8.21'
|
kotlin_version = '1.8.21'
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:8.2.2'
|
classpath 'com.android.tools.build:gradle:8.3.0'
|
||||||
classpath 'com.google.gms:google-services:4.4.0'
|
classpath 'com.google.gms:google-services:4.4.0'
|
||||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.1'
|
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.1'
|
||||||
}
|
}
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Tue Feb 27 16:09:58 IST 2024
|
#Tue Feb 27 16:09:58 IST 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
Reference in New Issue
Block a user