From fae259914d847138993e25f9d948d9257e347561 Mon Sep 17 00:00:00 2001 From: sangjun park Date: Fri, 8 Nov 2024 19:22:36 +0900 Subject: [PATCH] Backup WIP:ActivityRecognitionStatCollector --- .../kaist/iclab/field_tracker/KoinModule.kt | 6 ++-- .../kaist/iclab/field_tracker/MainActivity.kt | 30 +++++++++++-------- tracker-library/src/main/AndroidManifest.xml | 16 +++++----- .../ActivityRecognitionStatCollector.kt | 22 ++++++++++++-- 4 files changed, 48 insertions(+), 26 deletions(-) diff --git a/field-smartphone/src/main/java/kaist/iclab/field_tracker/KoinModule.kt b/field-smartphone/src/main/java/kaist/iclab/field_tracker/KoinModule.kt index c3f9cee..c624d09 100644 --- a/field-smartphone/src/main/java/kaist/iclab/field_tracker/KoinModule.kt +++ b/field-smartphone/src/main/java/kaist/iclab/field_tracker/KoinModule.kt @@ -35,7 +35,7 @@ val appModule = module { // singleOf(::ActivityTransitionCollector) singleOf(::AmbientLightCollector) -// singleOf(::ActivityRecognitionStatCollector) + singleOf(::ActivityRecognitionStatCollector) // singleOf(::AppUsageLogCollector) singleOf(::BatteryCollector) // singleOf(::CallLogCollector) @@ -54,8 +54,8 @@ val appModule = module { get(), // get(), // get(), - get() -// get() + get(), + get() // get() // get() ).map({ it.NAME to it }).toMap() diff --git a/field-smartphone/src/main/java/kaist/iclab/field_tracker/MainActivity.kt b/field-smartphone/src/main/java/kaist/iclab/field_tracker/MainActivity.kt index f16f9dc..08b44aa 100644 --- a/field-smartphone/src/main/java/kaist/iclab/field_tracker/MainActivity.kt +++ b/field-smartphone/src/main/java/kaist/iclab/field_tracker/MainActivity.kt @@ -1,7 +1,12 @@ package kaist.iclab.field_tracker import android.Manifest +import android.app.PendingIntent +import android.content.BroadcastReceiver +import android.content.Context import android.content.Intent +import android.content.IntentFilter +import android.content.pm.PackageManager import android.os.Build import android.os.Bundle import android.provider.ContactsContract.Data @@ -12,14 +17,23 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.ui.Modifier +import androidx.core.app.ActivityCompat +import com.google.android.gms.location.ActivityRecognition +import com.google.android.gms.location.ActivityRecognitionClient +import com.google.android.gms.location.ActivityRecognitionResult +import com.google.android.gms.location.DetectedActivity import com.google.android.gms.location.LocationServices import kaist.iclab.tracker.permission.PermissionActivity import kaist.iclab.field_tracker.ui.MainScreen import kaist.iclab.field_tracker.ui.theme.TrackerTheme import kaist.iclab.tracker.Tracker +import kaist.iclab.tracker.collectors.ActivityRecognitionStatCollector +import kaist.iclab.tracker.collectors.ActivityRecognitionStatCollector.Entity import kaist.iclab.tracker.collectors.DataTrafficStatCollector import kaist.iclab.tracker.collectors.LocationCollector import kaist.iclab.tracker.controller.DataEntity +import kaist.iclab.tracker.triggers.SystemBroadcastTrigger +import org.koin.android.ext.android.get import org.koin.androidx.compose.KoinAndroidContext class MainActivity : PermissionActivity() { @@ -40,20 +54,12 @@ class MainActivity : PermissionActivity() { } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { Tracker.getPermissionManager().request( - arrayOf(Manifest.permission.POST_NOTIFICATIONS, - Manifest.permission.SCHEDULE_EXACT_ALARM) - ){ + arrayOf(Manifest.permission.POST_NOTIFICATIONS) +// Manifest.permission.SCHEDULE_EXACT_ALARM) + ) { Log.d("MAIN_ACTIVITY", "Permission $it") } } -// startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)) -// val context = this@MainActivity -// val client = LocationServices.getFusedLocationProviderClient(context) - -// val newLocation = LocationCollector(this, Tracker.getPermissionManager()) -// newLocation.listener = { data:DataEntity -> -// Log.d(newLocation.NAME, "Data: $data") -// } -// newLocation.start() } + } \ No newline at end of file diff --git a/tracker-library/src/main/AndroidManifest.xml b/tracker-library/src/main/AndroidManifest.xml index 5d42657..b4ec1cd 100644 --- a/tracker-library/src/main/AndroidManifest.xml +++ b/tracker-library/src/main/AndroidManifest.xml @@ -27,17 +27,17 @@ - - - - - + + + + + + + = Build.VERSION_CODES.S) PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + else PendingIntent.FLAG_UPDATE_CURRENT ) }