diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3d2fbbb..ab47502 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,8 +15,8 @@ android { applicationId = "org.eclipse.ecsp" minSdk = 24 targetSdk = 35 - versionCode = 16 - versionName = "3.5" + versionCode = 18 + versionName = "3.8" multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -68,8 +68,7 @@ android { dependencies { - implementation("org.eclipse.ecsp:vehicleconnectsdk:1.1.5") -// implementation(files("libs/androidVehicleConnectSDK.aar")) + implementation("org.eclipse.ecsp:vehicleconnectsdk:1.1.7") implementation("androidx.core:core-ktx:1.15.0") implementation("androidx.activity:activity-compose:1.8.0") implementation("androidx.compose.ui:ui:1.5.0") @@ -105,5 +104,5 @@ dependencies { implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") implementation(kotlin("reflect")) - implementation("com.google.firebase:firebase-messaging:24.0.0") + implementation("com.google.firebase:firebase-messaging:24.1.1") } diff --git a/app/src/main/java/org/eclipse/ecsp/helper/FcmNotificationService.kt b/app/src/main/java/org/eclipse/ecsp/helper/FcmNotificationService.kt index dcb1511..960613e 100644 --- a/app/src/main/java/org/eclipse/ecsp/helper/FcmNotificationService.kt +++ b/app/src/main/java/org/eclipse/ecsp/helper/FcmNotificationService.kt @@ -29,11 +29,10 @@ import org.eclipse.ecsp.R import org.eclipse.ecsp.helper.AppConstants.EXTRA_ALERT import org.eclipse.ecsp.helper.AppConstants.EXTRA_MESSAGE import org.eclipse.ecsp.helper.AppConstants.EXTRA_VEHICLE_ID +import org.eclipse.ecsp.notificationservice.model.AlertData import org.eclipse.ecsp.ui.theme.LightBlue import org.eclipse.ecsp.ui.view.activities.DashboardActivity import org.eclipse.ecsp.ui.view.activities.LoginActivity -import org.eclipse.ecsp.helper.AppManager -import org.eclipse.ecsp.notificationservice.model.AlertData /** * Represents the notification service listener, using firebase messaging service. @@ -52,7 +51,15 @@ class FcmNotificationService : FirebaseMessagingService() { */ override fun onMessageReceived(message: RemoteMessage) { if (message.data.isNotEmpty()) { - Log.d("FCM_SERVICE", message.data.toString()) + val data = message.data + Log.d("FCM_SERVICE", data.toString()) + val body: String = data["body"].toString() + val chanelId = + if (data.keys.contains("channelIdentifier")) + data["channelIdentifier"] ?: "" + else + "" + showNotification(chanelId, body, ) } } @@ -72,11 +79,11 @@ class FcmNotificationService : FirebaseMessagingService() { private fun showNotification( channelId: String, message: String, - vehicleId: String, - alert: AlertData, +// vehicleId: String, +// alert: AlertData ) { val notificationId = (System.currentTimeMillis() and 0xfffffffL).toInt() - val intent = getPendingIntent(message, alert, vehicleId) + val intent = getPendingIntent(message) val pendingIntent = PendingIntent.getActivity( this, @@ -134,8 +141,8 @@ class FcmNotificationService : FirebaseMessagingService() { */ private fun getPendingIntent( message: String, - alert: AlertData, - vehicleId: String, +// alert: AlertData, + vehicleId: String?=null ): Intent { val intent: Intent if (AppManager.isLoggedIn()) { @@ -146,7 +153,7 @@ class FcmNotificationService : FirebaseMessagingService() { intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK } intent.putExtra(EXTRA_MESSAGE, message) - intent.putExtra(EXTRA_ALERT, alert) +// intent.putExtra(EXTRA_ALERT, alert) intent.putExtra(EXTRA_VEHICLE_ID, vehicleId) intent.action = System.currentTimeMillis().toString() return intent diff --git a/app/src/main/java/org/eclipse/ecsp/models/dataclass/VehicleProfileModel.kt b/app/src/main/java/org/eclipse/ecsp/models/dataclass/VehicleProfileModel.kt index da0c6d2..57094ce 100644 --- a/app/src/main/java/org/eclipse/ecsp/models/dataclass/VehicleProfileModel.kt +++ b/app/src/main/java/org/eclipse/ecsp/models/dataclass/VehicleProfileModel.kt @@ -29,5 +29,5 @@ import org.eclipse.ecsp.vehicleservice.model.vehicleprofile.VehicleDetailData @Parcelize data class VehicleProfileModel( var associatedDevice: AssociatedDevice, - var vehicleDetailData: VehicleDetailData?, + var vehicleDetailData: VehicleDetailData?=null, ) : Parcelable diff --git a/app/src/main/java/org/eclipse/ecsp/models/viewmodels/DashboardVM.kt b/app/src/main/java/org/eclipse/ecsp/models/viewmodels/DashboardVM.kt index ecd5f65..40d15c8 100644 --- a/app/src/main/java/org/eclipse/ecsp/models/viewmodels/DashboardVM.kt +++ b/app/src/main/java/org/eclipse/ecsp/models/viewmodels/DashboardVM.kt @@ -1,4 +1,5 @@ package org.eclipse.ecsp.models.viewmodels + /******************************************************************************** * Copyright (c) 2023-24 Harman International * @@ -17,6 +18,7 @@ package org.eclipse.ecsp.models.viewmodels ********************************************************************************/ import android.app.Activity import android.util.Log +import android.widget.Toast import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData @@ -30,6 +32,7 @@ import org.eclipse.ecsp.helper.response.CustomMessage import org.eclipse.ecsp.notificationservice.model.ChannelData import org.eclipse.ecsp.notificationservice.model.NotificationConfigData import org.eclipse.ecsp.userservice.service.UserServiceInterface +import java.lang.ref.WeakReference /** * Represents the Dashboard ViewModel @@ -40,13 +43,14 @@ import org.eclipse.ecsp.userservice.service.UserServiceInterface */ class DashboardVM(activity: Activity) : AndroidViewModel(activity.application) { private var topBarTitle = MutableLiveData("") - private var _associatedDeviceList = MutableLiveData>>() + private var _associatedDeviceList = MutableLiveData>() private val dashboardRepository: DashboardRepository by lazy { DashboardRepository() } private var isSignOutClicked = MutableLiveData(false) private var _isPasswordChangeTriggered = MutableLiveData(false) private var passwordChangeStatus = MutableLiveData>() + private var weakReference = WeakReference(activity) /** * Represents to get the title value of the screens @@ -71,16 +75,30 @@ class DashboardVM(activity: Activity) : AndroidViewModel(activity.application) { * * @return [HashMap] of [VehicleProfileModel] LiveData */ - fun getAssociatedDeviceList(): LiveData>> { + fun getAssociatedDeviceList(): LiveData> { return _associatedDeviceList } /** * Represents to set the associated vehicle list to [_associatedDeviceList] + * Function is calling both associated vehicle list and respective vehicles profile data API * */ fun fetchAssociateDeviceList() { - _associatedDeviceList = dashboardRepository.associateDeviceList() + viewModelScope.launch { + val deviceList = dashboardRepository.getAssociatedDeviceList() + if (deviceList != null) { + val vehicleProfileData = dashboardRepository.getVehicleProfileData(deviceList) + if (vehicleProfileData.isNotEmpty()) + _associatedDeviceList.postValue(vehicleProfileData) + else + Toast.makeText(weakReference.get(), "Vehicle Profile API failed during operation ", Toast.LENGTH_SHORT) + .show() + } else { + Toast.makeText(weakReference.get(), "Device list API failed", Toast.LENGTH_SHORT) + .show() + } + } } /** @@ -131,17 +149,21 @@ class DashboardVM(activity: Activity) : AndroidViewModel(activity.application) { fun isPasswordChangeTriggered(): LiveData = _isPasswordChangeTriggered - fun setPasswordChangeTriggerValue(value: Boolean){ + fun setPasswordChangeTriggerValue(value: Boolean) { _isPasswordChangeTriggered.value = value } - fun changePasswordApiCall(userServiceInterface: UserServiceInterface): LiveData>{ + fun changePasswordApiCall(userServiceInterface: UserServiceInterface): LiveData> { val exception = CoroutineExceptionHandler { _, exception -> Log.e("Password change request API failed: ", exception.cause.toString()) } viewModelScope.launch(exception) { - passwordChangeStatus.postValue(dashboardRepository.requestForChangePassword(userServiceInterface)) + passwordChangeStatus.postValue( + dashboardRepository.requestForChangePassword( + userServiceInterface + ) + ) } return passwordChangeStatus } diff --git a/app/src/main/java/org/eclipse/ecsp/models/viewmodels/DeviceAssociationVM.kt b/app/src/main/java/org/eclipse/ecsp/models/viewmodels/DeviceAssociationVM.kt index dc688f9..896cd71 100644 --- a/app/src/main/java/org/eclipse/ecsp/models/viewmodels/DeviceAssociationVM.kt +++ b/app/src/main/java/org/eclipse/ecsp/models/viewmodels/DeviceAssociationVM.kt @@ -16,6 +16,7 @@ package org.eclipse.ecsp.models.viewmodels * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ import android.app.Activity +import android.util.Log import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData @@ -102,9 +103,7 @@ class DeviceAssociationVM(activity: Activity) : AndroidViewModel(activity.applic imeiString: String, ): MutableLiveData> { viewModelScope.launch { - vehicleServiceInterface.verifyDeviceImei(imeiString) { - _verifyDeviceIMEI.value = it - } + _verifyDeviceIMEI.postValue(vehicleServiceInterface.verifyDeviceImei(imeiString)) } return _verifyDeviceIMEI } @@ -120,10 +119,15 @@ class DeviceAssociationVM(activity: Activity) : AndroidViewModel(activity.applic vehicleServiceInterface: VehicleServiceInterface, serialString: String, ): MutableLiveData> { - viewModelScope.launch { - vehicleServiceInterface.associateDevice(serialString) { - _associateDevice.value = it + try { + viewModelScope.launch { + val result = vehicleServiceInterface.associateDevice(serialString) + if(result.status.requestStatus){ + _associateDevice.value = result + } } + } catch (e: Exception){ + Log.e("DEVICE_ASSOCIATION: ", e.cause.toString()) } return _associateDevice } diff --git a/app/src/main/java/org/eclipse/ecsp/models/viewmodels/RemoteOperationVM.kt b/app/src/main/java/org/eclipse/ecsp/models/viewmodels/RemoteOperationVM.kt index 8983748..5da539e 100644 --- a/app/src/main/java/org/eclipse/ecsp/models/viewmodels/RemoteOperationVM.kt +++ b/app/src/main/java/org/eclipse/ecsp/models/viewmodels/RemoteOperationVM.kt @@ -21,7 +21,9 @@ import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.viewModelScope import com.google.gson.Gson +import kotlinx.coroutines.launch import org.eclipse.ecsp.helper.response.CustomMessage import org.eclipse.ecsp.roservice.model.RemoteOperationState import org.eclipse.ecsp.roservice.model.RoEventHistoryResponse @@ -232,20 +234,20 @@ class RemoteOperationVM(activity: Activity) : AndroidViewModel(activity.applicat userId: String, vehicleId: String, ) { - dashboardRepository.getRemoteOperationHistory(userId, vehicleId) - .observe(lifecycleOwner) { roEventHistoryResponse -> - isProgressBarLoading?.value = false - if(roEventHistoryResponse.status.requestStatus) { - updateListOnRoHistory( - activity, - roEventHistoryResponse, - lazyStaggeredGridList, - notifyRoUpdate, - ) - } else{ - toastError(activity, "RO History: ${roEventHistoryResponse.error?.message ?: "Error occurred"}") - } + viewModelScope.launch { + val roEventHistoryResponse = dashboardRepository.getRemoteOperationHistory(userId, vehicleId) + isProgressBarLoading?.value = false + if(roEventHistoryResponse.status.requestStatus){ + updateListOnRoHistory( + activity, + roEventHistoryResponse, + lazyStaggeredGridList, + notifyRoUpdate, + ) + } else { + toastError(activity, "RO History: ${roEventHistoryResponse.error?.message ?: "Error occurred"}") } + } } /*fun cancelJob() { @@ -326,13 +328,14 @@ class RemoteOperationVM(activity: Activity) : AndroidViewModel(activity.applicat duration: Int? = null, isFromClickAction: Boolean = false, ) { - dashboardRepository.updateRoState( - userId, - vehicleId, - remoteOperationState, - percentage, - duration, - ).observe(lifecycleOwner) { roStatusResponse -> + viewModelScope.launch { + val roStatusResponse = dashboardRepository.updateRoState( + userId, + vehicleId, + remoteOperationState, + percentage, + duration, + ) isProgressBarLoading?.value = false if (!isFromClickAction) { updateROStatus( diff --git a/app/src/main/java/org/eclipse/ecsp/repository/DashboardRepository.kt b/app/src/main/java/org/eclipse/ecsp/repository/DashboardRepository.kt index 2901410..724804d 100644 --- a/app/src/main/java/org/eclipse/ecsp/repository/DashboardRepository.kt +++ b/app/src/main/java/org/eclipse/ecsp/repository/DashboardRepository.kt @@ -16,6 +16,7 @@ package org.eclipse.ecsp.repository * * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ +import android.annotation.SuppressLint import android.util.Log import androidx.lifecycle.MutableLiveData import org.eclipse.ecsp.helper.AppConstants.DISASSOCIATED @@ -24,9 +25,14 @@ import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.async import kotlinx.coroutines.launch +import kotlinx.coroutines.plus +import kotlinx.coroutines.supervisorScope import org.eclipse.ecsp.helper.response.CustomMessage +import org.eclipse.ecsp.helper.response.error.CustomError +import org.eclipse.ecsp.helper.response.error.Status import org.eclipse.ecsp.notificationservice.model.AlertAnalysisData import org.eclipse.ecsp.notificationservice.model.NotificationConfigData import org.eclipse.ecsp.notificationservice.service.NotificationServiceInterface @@ -59,24 +65,24 @@ class DashboardRepository { * @param userId as [String] * @param vehicleId as [String] * @param roRequestId Ro request id as [String] - * @return [MutableLiveData] of [RoEventHistoryResponse]'s [CustomMessage] + * @return [CustomMessage] */ - fun checkRoRequestStatus( + suspend fun checkRoRequestStatus( userId: String, vehicleId: String, roRequestId: String, - ): MutableLiveData> { - val data = MutableLiveData>() - val exception = - CoroutineExceptionHandler { _, exception -> - Log.e("RO Request Status API failed: ", exception.cause.toString()) - } - CoroutineScope(Dispatchers.IO).launch(exception) { - roServiceInterface.checkRemoteOperationRequestStatus(userId, vehicleId, roRequestId) { - data.postValue(it) - } + ): CustomMessage { + var resp = CustomMessage(Status.Failure) + try { + resp = roServiceInterface.checkRemoteOperationRequestStatus(userId, vehicleId, roRequestId) + } catch (exception: Exception) { + Log.e("RO Request Status API failed: ", exception.printStackTrace().toString()) + CustomMessage( + Status.Failure, + CustomError.Generic(exception.printStackTrace().toString()) + ) } - return data + return resp } /** @@ -87,30 +93,30 @@ class DashboardRepository { * @param remoteOperationState [RemoteOperationState] value * @param percentage as [Long] * @param duration as [Long] - * @return + * @return [CustomMessage] */ - fun updateRoState( + suspend fun updateRoState( userId: String, vehicleId: String, remoteOperationState: RemoteOperationState, percentage: Int? = null, duration: Int? = null, - ): MutableLiveData> { - val data = MutableLiveData>() - val exception = - CoroutineExceptionHandler { _, exception -> - Log.e("RO State Update API failed: ", exception.cause.toString()) - } - CoroutineScope(Dispatchers.IO).launch(exception) { - roServiceInterface.updateROStateRequest( + ): CustomMessage { + var data: CustomMessage + try { + data = roServiceInterface.updateROStateRequest( userId, vehicleId, percentage, duration, remoteOperationState, - ) { - data.postValue(it) - } + ) + } catch (exception: Exception) { + Log.e("RO State Update API failed: ", exception.printStackTrace().toString()) + data = CustomMessage( + Status.Failure, + CustomError.Generic(exception.printStackTrace().toString()) + ) } return data } @@ -120,23 +126,23 @@ class DashboardRepository { * * @param userId as [String] * @param vehicleId as [String] - * @return [MutableLiveData] of [RoEventHistoryResponse]'s [CustomMessage] + * @return [CustomMessage] */ - fun getRemoteOperationHistory( + suspend fun getRemoteOperationHistory( userId: String, vehicleId: String, - ): MutableLiveData>> { - val data = MutableLiveData>>() - val exception = - CoroutineExceptionHandler { _, exception -> - Log.e("RO History Status API failed: ", exception.cause.toString()) - } - CoroutineScope(Dispatchers.IO).launch(exception) { - roServiceInterface.getRemoteOperationHistory(userId, vehicleId) { - data.postValue(it) - } + ): CustomMessage> { + var resp: CustomMessage> + try { + resp = roServiceInterface.getRemoteOperationHistory(userId, vehicleId) + } catch (exception: Exception) { + Log.e("RO History Status API failed: ", exception.printStackTrace().toString()) + resp = CustomMessage( + Status.Failure, + CustomError.Generic(exception.printStackTrace().toString()) + ) } - return data + return resp } /** @@ -182,45 +188,49 @@ class DashboardRepository { } /** - * Functions is to get the associated device list using SDK Api + * Function is to fetch the associated device list * - * @return [MutableLiveData] of [HashMap] + * @return [List] of [AssociatedDevice] */ - fun associateDeviceList(): MutableLiveData>> { - val data = MutableLiveData>>() - val exception = - CoroutineExceptionHandler { _, exception -> - Log.e( - "Device association list and vehicle profile API failed: ", - exception.cause.toString(), - ) - } - CoroutineScope(Dispatchers.IO).launch(exception) { - val list = HashMap() - val deviceCall = - async { - var deviceAssociationListData: List? = - null - vehicleServiceInterface.associatedDeviceList { - if (it.response != null) { - deviceAssociationListData = - it.response?.data?.filter { deviceList -> - deviceList.mDeviceId != null && deviceList.mAssociationStatus != DISASSOCIATED - } - } + suspend fun getAssociatedDeviceList(): List? { + var data: List? = null + try { + val result = vehicleServiceInterface.associatedDeviceList() + if (result.status.requestStatus && result.response != null) { + data = + result.response?.data?.filter { deviceList -> + deviceList.mDeviceId != null && deviceList.mAssociationStatus != DISASSOCIATED } - return@async deviceAssociationListData - } + } + + } catch (exception: Exception) { + Log.e( + "Device association list API failed: ", exception.cause.toString(), + ) + } + return data + } - val vehicleProfileDataCall: Deferred>> = - async { - var success = false - deviceCall.await()?.forEach { - if (it.mDeviceId != null) { - vehicleServiceInterface.getVehicleProfile(it.mDeviceId!!) { vehicleProfileData -> + /** + * Function is to fetch the vehicle profile data of each associated device. + * + * @param deviceList contains all the associated device which are not DISASSOCIATED + * @return [HashMap] of [VehicleProfileModel] which contains only the device which having the device id + */ + suspend fun getVehicleProfileData(deviceList: List): HashMap { + val list = HashMap() + try { + supervisorScope { + deviceList.forEach { + launch { + try { + if (it.mDeviceId != null) { + list[it.mDeviceId!!] = VehicleProfileModel(it) + val vehicleProfileData = vehicleServiceInterface.getVehicleProfile(it.mDeviceId!!) if (vehicleProfileData.response != null && vehicleProfileData.response?.data != null - && vehicleProfileData.response!!.data!!.isNotEmpty()) { + && vehicleProfileData.response!!.data!!.isNotEmpty() + ) { list[it.mDeviceId!!] = VehicleProfileModel( it, @@ -228,17 +238,22 @@ class DashboardRepository { ) } } - success = true + } catch (e: Exception) { + Log.e( + "Vehicle Profile API failed for ${it.mDeviceId}: ", + e.cause.toString(), + ) } - }?.let { - success = false } - return@async Pair(success, list) } - - data.postValue(vehicleProfileDataCall.await()) + } + } catch (e: Exception) { + Log.e( + "Vehicle Profile API failed by coroutine cancellation: ", + e.cause.toString(), + ) } - return data + return list } /** @@ -255,18 +270,22 @@ class DashboardRepository { ) { val exception = CoroutineExceptionHandler { _, exception -> - Log.e("Notification config data subscribe API failed: ", exception.cause.toString()) + Log.e( + "NOTIFICATION_SUBSCRIPTION API", + "Notification config data subscribe API failed: ${exception.cause.toString()}" + ) } CoroutineScope(Dispatchers.IO).launch(exception) { - notificationServiceInterface.updateNotificationConfig( + val result = notificationServiceInterface.updateNotificationConfig( userId, vehicleId, null, notificationConfigDataList, - ) { + ) + if (result.status.requestStatus) { Log.d( "NOTIFICATION_SUBSCRIPTION API", - "Notification subscription api success for $vehicleId" + "Notification subscription api response for $vehicleId -> ${result.response}" ) } } diff --git a/app/src/main/java/org/eclipse/ecsp/repository/LoginRepository.kt b/app/src/main/java/org/eclipse/ecsp/repository/LoginRepository.kt index e4eaa48..f5f31fe 100644 --- a/app/src/main/java/org/eclipse/ecsp/repository/LoginRepository.kt +++ b/app/src/main/java/org/eclipse/ecsp/repository/LoginRepository.kt @@ -42,9 +42,8 @@ class LoginRepository { Log.e("User Profile API: ", exception.cause.toString()) } CoroutineScope(Dispatchers.IO).launch(exception) { - userServiceInterface.fetchUserProfile { - data.postValue(it) - } + data.postValue(userServiceInterface.fetchUserProfile()) + } return data } diff --git a/app/src/main/java/org/eclipse/ecsp/repository/VehicleProfileRepository.kt b/app/src/main/java/org/eclipse/ecsp/repository/VehicleProfileRepository.kt index 5ee81bc..5753e79 100644 --- a/app/src/main/java/org/eclipse/ecsp/repository/VehicleProfileRepository.kt +++ b/app/src/main/java/org/eclipse/ecsp/repository/VehicleProfileRepository.kt @@ -51,9 +51,7 @@ class VehicleProfileRepository { Log.e("Device association list API: ", exception.cause.toString()) } CoroutineScope(Dispatchers.IO).launch(exception) { - vehicleServiceInterface.updateVehicleProfile(deviceId, postVehicleAttributeData) { - data.postValue(it) - } + data.postValue(vehicleServiceInterface.updateVehicleProfile(deviceId, postVehicleAttributeData)) } return data } @@ -71,9 +69,7 @@ class VehicleProfileRepository { Log.e("Device termination API: ", exception.cause.toString()) } CoroutineScope(Dispatchers.IO).launch(exception) { - vehicleServiceInterface.terminateVehicle(terminateDeviceData) { - data.postValue(it) - } + data.postValue(vehicleServiceInterface.terminateVehicle(terminateDeviceData)) } return data } diff --git a/app/src/main/java/org/eclipse/ecsp/services/RoRequestLoopService.kt b/app/src/main/java/org/eclipse/ecsp/services/RoRequestLoopService.kt index afee668..936ef52 100644 --- a/app/src/main/java/org/eclipse/ecsp/services/RoRequestLoopService.kt +++ b/app/src/main/java/org/eclipse/ecsp/services/RoRequestLoopService.kt @@ -1,4 +1,5 @@ package org.eclipse.ecsp.services + /******************************************************************************** * Copyright (c) 2023-24 Harman International * @@ -69,13 +70,15 @@ class RoRequestLoopService( while (isActive) { if (count <= 50) { count += 1 - dashboardRepository.checkRoRequestStatus(userId, vehicleId, roRequestId) - .observe(lifecycleOwner) { roEventHistoryResponse -> - updateRemoteUI( - activity, roEventHistoryResponse, isProgressBarLoading, - lazyStaggeredGridList, notifyRoUpdate, - ) - } + val roEventHistoryResponse = dashboardRepository.checkRoRequestStatus( + userId, + vehicleId, + roRequestId + ) + updateRemoteUI( + activity, roEventHistoryResponse, isProgressBarLoading, + lazyStaggeredGridList, notifyRoUpdate, + ) delay(10000) } else { cancelJob() @@ -124,7 +127,10 @@ class RoRequestLoopService( notifyRoUpdate.value = notifyRoUpdate.value + 1 } cancelJob() - toastError(activity, "${getEventType(response.roEvents.eventID)} Remote operation failed") + toastError( + activity, + "${getEventType(response.roEvents.eventID)} Remote operation failed" + ) } else { Log.d("PENDING_STATE", "within 3 min") var tempList = lazyStaggeredGridList?.value @@ -149,7 +155,10 @@ class RoRequestLoopService( notifyRoUpdate.value = notifyRoUpdate.value + 1 } cancelJob() - toastError(activity, "${getEventType(response.roEvents.eventID)} Remote operation failed") + toastError( + activity, + "${getEventType(response.roEvents.eventID)} Remote operation failed" + ) } } } else { @@ -157,7 +166,7 @@ class RoRequestLoopService( } } - private fun getEventType(eventId: String?): String { + private fun getEventType(eventId: String?): String { return when (eventId) { AppConstants.WINDOW_EVENT_ID -> WINDOWS AppConstants.LIGHTS_EVENT_ID -> LIGHT diff --git a/app/src/main/java/org/eclipse/ecsp/ui/view/activities/DashboardActivity.kt b/app/src/main/java/org/eclipse/ecsp/ui/view/activities/DashboardActivity.kt index 554a5a4..84cfeea 100644 --- a/app/src/main/java/org/eclipse/ecsp/ui/view/activities/DashboardActivity.kt +++ b/app/src/main/java/org/eclipse/ecsp/ui/view/activities/DashboardActivity.kt @@ -130,7 +130,7 @@ class DashboardActivity : BaseAppActivity() { } } } -// askNotificationPermission() + askNotificationPermission() } override fun onResume() { @@ -164,9 +164,9 @@ class DashboardActivity : BaseAppActivity() { ) )) ) + dashboardVM.fetchAssociateDeviceList() LaunchedEffect(Unit) { - dashboardVM.fetchAssociateDeviceList() - triggerDeviceAssociationListApi() + triggerDeviceAssociationListApi(userProfile?.mEmail ?: "") } dashboardVM.isSignOutClicked().observe(this@DashboardActivity) { isSignOut -> if (isSignOut) { @@ -276,14 +276,14 @@ class DashboardActivity : BaseAppActivity() { } } - private fun triggerDeviceAssociationListApi() { -// isProgressBarLoading.value = true + private fun triggerDeviceAssociationListApi(emailId: String) { + isProgressBarLoading.value = true dashboardVM.getAssociatedDeviceList().observe(this@DashboardActivity) { -// dashboardVM.subscribeNotificationConfig(emailId?:"", it) + dashboardVM.subscribeNotificationConfig(emailId, it) isProgressBarLoading.value = false it.let { - AppConstants.setVehicleList(this@DashboardActivity, Gson().toJson(it.second)) - processVehicleList(it.second) + AppConstants.setVehicleList(this@DashboardActivity, Gson().toJson(it)) + processVehicleList(it) } } } diff --git a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardVehicleListCompose.kt b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardVehicleListCompose.kt index 8cdc90e..9ced508 100644 --- a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardVehicleListCompose.kt +++ b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardVehicleListCompose.kt @@ -224,7 +224,7 @@ fun VehicleSelectionListView( val vehicleStatus = AppConstants.getVehicleStatus(item?.associatedDevice?.mAssociationStatus) Text( text = ( - "${item?.vehicleDetailData?.vehicleAttributes?.name + "${item?.vehicleDetailData?.vehicleAttributes?.name ?: item?.associatedDevice?.mDeviceId ?: "No Device Id"}-$vehicleStatus" ), modifier = diff --git a/build.gradle.kts b/build.gradle.kts index 96a8bda..f28abbd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ plugins { id("org.cyclonedx.bom") version ("1.9.0") + id("com.google.gms.google-services") version "4.4.2" apply false } subprojects { diff --git a/eclipse-dash/dash.sh b/eclipse-dash/dash.sh index 289a46c..6c7ed97 100644 --- a/eclipse-dash/dash.sh +++ b/eclipse-dash/dash.sh @@ -6,7 +6,7 @@ chmod +x 'gradlew' echo 'Checking dependencies for SDK implemented sample app Module' -'./gradlew' 'app:dependencies' | 'grep' '-Poh' "(?<=\-\-\- ).*" | 'grep' '-Pv' "\([c\*]\)" | 'grep' '-Pv' "\([n\*]\)" | 'perl' '-pe' 's/([\w\.\-]+):([\w\.\-]+):(?:[\w\.\-]+ -> )?([\w\.\-]+).*$/$1:$2:$3/gmi;t' | 'sort' -u | 'grep' '-v' 'project :androidVehicleConnectSDK' | 'grep' '-v' 'com.google.android.gms:play-services-basement:16.0.1' | 'grep' '-v' 'com.google.android.gms:play-services-basement:18.3.0' | 'grep' '-v' 'com.google.android.gms:play-services-tasks:16.0.1' | 'grep' '-v' 'com.google.android.gms:play-services-tasks:18.1.0' | 'grep' '-v' 'com.google.android.datatransport:transport-api:3.0.0' | 'grep' '-v' 'com.google.android.gms:play-services-base:18.0.1' | 'grep' '-v' 'com.google.android.gms:play-services-basement:18.0.0' | 'grep' '-v' 'com.google.android.gms:play-services-cloud-messaging:17.2.0' | 'grep' '-v' 'com.google.android.gms:play-services-stats:17.0.2' | 'grep' '-v' 'com.google.android.gms:play-services-tasks:18.0.1' | 'grep' '-v' 'com.google.firebase:firebase-annotations:16.2.0' | 'grep' '-v' 'com.google.firebase:firebase-iid-interop:17.1.0' | 'grep' '-v' 'com.google.firebase:firebase-measurement-connector:19.0.0' > 'AppDependencies' +'./gradlew' 'app:dependencies' | 'grep' '-Poh' "(?<=\-\-\- ).*" | 'grep' '-Pv' "\([c\*]\)" | 'grep' '-Pv' "\([n\*]\)" | 'perl' '-pe' 's/([\w\.\-]+):([\w\.\-]+):(?:[\w\.\-]+ -> )?([\w\.\-]+).*$/$1:$2:$3/gmi;t' | 'sort' -u | 'grep' '-v' 'project :androidVehicleConnectSDK' | 'grep' '-v' 'com.google.android.gms:play-services-basement:16.0.1' | 'grep' '-v' 'com.google.android.gms:play-services-basement:18.3.0' | 'grep' '-v' 'com.google.android.gms:play-services-tasks:16.0.1' | 'grep' '-v' 'com.google.android.gms:play-services-tasks:18.1.0' | 'grep' '-v' 'com.google.android.datatransport:transport-api:3.0.0' | 'grep' '-v' 'com.google.android.gms:play-services-base:18.1.0' | 'grep' '-v' 'com.google.android.gms:play-services-basement:18.0.0' | 'grep' '-v' 'com.google.android.gms:play-services-cloud-messaging:17.2.0' | 'grep' '-v' 'com.google.android.gms:play-services-stats:17.0.2' | 'grep' '-v' 'com.google.android.gms:play-services-tasks:18.0.1' | 'grep' '-v' 'com.google.firebase:firebase-annotations:16.2.0' | 'grep' '-v' 'com.google.firebase:firebase-iid-interop:17.1.0' | 'grep' '-v' 'com.google.firebase:firebase-measurement-connector:19.0.0' | 'grep' '-v' 'com.google.firebase:firebase-messaging:24.1.1' > 'AppDependencies' echo 'Tool checking for SDK dependencies'