Skip to content

Commit

Permalink
WIP: AmbientLightCollector Initialization Error
Browse files Browse the repository at this point in the history
  • Loading branch information
highjun committed Nov 6, 2024
1 parent e81ff2a commit 40a56e6
Show file tree
Hide file tree
Showing 57 changed files with 1,726 additions and 1,458 deletions.
Binary file modified field-smartphone/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,63 @@ package kaist.iclab.field_tracker
import kaist.iclab.field_tracker.ui.AbstractMainViewModel
import kaist.iclab.field_tracker.ui.MainViewModelImpl
import kaist.iclab.tracker.Tracker
import kaist.iclab.tracker.collectors.*
import kaist.iclab.tracker.TrackerUtil
import kaist.iclab.tracker.collectors.AmbientLightCollector
import kaist.iclab.tracker.controller.CollectorControllerInterface
import kaist.iclab.tracker.database.DatabaseInterface
import kaist.iclab.tracker.database.TempDBImpl
import kaist.iclab.tracker.controller.CollectorInterface
import kaist.iclab.tracker.notf.NotfManagerInterface
import kaist.iclab.tracker.permission.PermissionManagerInterface
import org.koin.android.ext.koin.androidContext
import org.koin.core.module.dsl.viewModel
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module


val appModule = module {
// singleOf(::ActivityTransitionCollector)
singleOf(::AmbientLightCollector)
// singleOf(::AppUsageLogCollector)
// singleOf(::BatteryCollector)
// singleOf(::CallLogCollector)
// singleOf(::DataTrafficStatCollector)
// singleOf(::LocationCollector)
// singleOf(::MessageLogCollector)
// singleOf(::NotificationCollector)
// singleOf(::ScreenCollector)
// singleOf(::UserInteractionCollector)
// singleOf(::WiFiScanCollector)

single<Map<String, CollectorInterface>> {
mapOf(
// "ActivityTransitionCollector" to get<ActivityTransitionCollector>(),
"AmbientLight" to get<AmbientLightCollector>(),
// "AppUsageLogCollector" to get<AppUsageLogCollector>(),
// "BatteryCollector" to get<BatteryCollector>(),
// "CallLogCollector" to get<CallLogCollector>(),
// "DataTrafficStatCollector" to get<DataTrafficStatCollector>(),
// "LocationCollector" to get<LocationCollector>(),
// "MessageLogCollector" to get<MessageLogCollector>(),
// "NotificationCollector" to get<NotificationCollector>(),
// "ScreenCollector" to get<ScreenCollector>(),
// "UserInteractionCollector" to get<UserInteractionCollector>(),
// "WiFiScanCollector" to get<WiFiScanCollector>()
)
}

single<CollectorControllerInterface> {
Tracker.getCollectorController()
}
single<PermissionManagerInterface> {
Tracker.getPermissionManager()
}
single<NotfManagerInterface> {
Tracker.getNotfManager()
}
single<DatabaseInterface> {
TempDBImpl(androidContext())
single<PermissionManagerInterface> {
Tracker.getPermissionManager()
}


singleOf(::ActivityTransitionCollector)
singleOf(::AmbientLightCollector)
singleOf(::AppUsageLogCollector)
singleOf(::BatteryCollector)
singleOf(::CallLogCollector)
singleOf(::DataTrafficStatCollector)
singleOf(::LocationCollector)
singleOf(::MessageLogCollector)
singleOf(::NotificationCollector)
singleOf(::ScreenCollector)
singleOf(::UserInteractionCollector)
singleOf(::WiFiScanCollector)
single<TrackerUtil> {
TrackerUtil(androidContext())
}

viewModel<AbstractMainViewModel> {
val collectors = mapOf(
"ActivityTransitionCollector" to get<ActivityTransitionCollector>(),
"AmbientLightCollector" to get<AmbientLightCollector>(),
"AppUsageLogCollector" to get<AppUsageLogCollector>(),
"BatteryCollector" to get<BatteryCollector>(),
"CallLogCollector" to get<CallLogCollector>(),
"DataTrafficStatCollector" to get<DataTrafficStatCollector>(),
"LocationCollector" to get<LocationCollector>(),
"MessageLogCollector" to get<MessageLogCollector>(),
"NotificationCollector" to get<NotificationCollector>(),
"ScreenCollector" to get<ScreenCollector>(),
"UserInteractionCollector" to get<UserInteractionCollector>(),
"WiFiScanCollector" to get<WiFiScanCollector>()
)
MainViewModelImpl(
get(),
get(),
get(),
collectors
)
single<AbstractMainViewModel>{
MainViewModelImpl(get(), get(), get<Map<String, CollectorInterface>>().keys.toTypedArray())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package kaist.iclab.field_tracker
import android.app.Application
import android.util.Log
import kaist.iclab.tracker.Tracker
import kaist.iclab.tracker.controller.CollectorControllerInterface
import kaist.iclab.tracker.controller.AbstractCollector
import kaist.iclab.tracker.controller.CollectorInterface
import kaist.iclab.tracker.notf.NotfManagerInterface
import org.koin.android.ext.android.get
import org.koin.android.ext.koin.androidContext
Expand All @@ -13,27 +14,27 @@ import org.koin.core.context.startKoin
class MainApplication: Application(){
override fun onCreate() {
super.onCreate()

Tracker.initialize(this@MainApplication)
startKoin {
androidLogger()
androidContext(this@MainApplication)
modules(appModule)
}
initConfiguration()
// Tracker.initialize(this@MainApplication, get(), get(), get())
// initConfiguration()
}

fun initConfiguration() {
val collectorController = get<CollectorControllerInterface>()
collectorController.collectors.forEach { collector ->
collector.listener = { data ->
Log.d(collector.NAME, "Data: $data")
}
}

val notfManager = get<NotfManagerInterface>()
notfManager.setServiceNotfDescription(
icon = R.drawable.ic_notf
)
}
// fun initConfiguration() {
// val collectorMap = get<Map<String, CollectorInterface>>()
// collectorMap.forEach { (name, collector) ->
// collector.listener = { data ->
// Log.d(collector.NAME, "Data: $data")
// }
// }
//
// val notfManager = get<NotfManagerInterface>()
// notfManager.setServiceNotfDescription(
// icon = R.drawable.ic_notf
// )
// }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package kaist.iclab.tracker.database

import android.net.Uri
import kaist.iclab.tracker.collectors.AbstractCollector
import kotlinx.coroutines.flow.Flow

interface DatabaseInterface {
Expand All @@ -21,9 +19,10 @@ interface DatabaseInterface {
// /*TODO: maybe UI required*/
// fun export()
//
// /*Update config including their enabled/disabled*/
/*Update config including their enabled/disabled*/
// fun updateConfig(name: String, config: AbstractCollector.Config)



fun updateConfig(name: String, value: Boolean)
fun getConfigFlow(): Flow<Map<String, Boolean>>
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
package kaist.iclab.field_tracker.ui

import androidx.lifecycle.ViewModel
import kaist.iclab.tracker.collectors.AbstractCollector
import kotlinx.coroutines.flow.MutableStateFlow
import kaist.iclab.tracker.controller.CollectorConfig
import kaist.iclab.tracker.controller.CollectorInterface
import kaist.iclab.tracker.controller.CollectorState
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow

abstract class AbstractMainViewModel: ViewModel() {
abstract val _isRunningState: MutableStateFlow<Boolean>
val isRunningState: StateFlow<Boolean>
get() = _isRunningState.asStateFlow()

abstract val collectorMap: Map<String, AbstractCollector>
abstract val _enabledCollectors: MutableStateFlow<Map<String, Boolean>>
val enabledCollectors: StateFlow<Map<String, Boolean>>
get() = _enabledCollectors.asStateFlow()

abstract fun start()
abstract fun stop()
abstract fun enable(name: String)
abstract fun disable(name: String)

abstract fun sync()
abstract fun delete()
}
abstract class AbstractMainViewModel: ViewModel(), MainViewModelInterface
Loading

0 comments on commit 40a56e6

Please sign in to comment.