Skip to content

Commit

Permalink
AirGuard Version 2.3 (#179)
Browse files Browse the repository at this point in the history
- This merges the changes underlying the support for Google Find My Device Trackers into the main branch
  • Loading branch information
Sn0wfreezeDev authored Jul 31, 2024
1 parent 0f869db commit 4224196
Show file tree
Hide file tree
Showing 39 changed files with 737 additions and 227 deletions.
2 changes: 1 addition & 1 deletion api.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
API_KEY="AGdk9qPF.Bl9yatnjjoy9WEEjXYGVewE7ZyJET9Yy"
API_KEY="aGUuBakn.mm4dTiqKAfN6akqkzggODoJjmMkGAoWL"
API_BASE_ADDRESS="https://tpe.seemoo.tu-darmstadt.de/api/"
71 changes: 32 additions & 39 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ plugins {
id 'kotlin-android'
id 'androidx.navigation.safeargs.kotlin'
id 'kotlin-kapt'
id 'com.google.devtools.ksp'
id 'dagger.hilt.android.plugin'
id 'com.mikepenz.aboutlibraries.plugin'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.compose'
id 'org.jetbrains.kotlin.plugin.compose' version "$kotlin_version"
}

def apiPropertiesFile = rootProject.file("api.properties")
Expand All @@ -26,19 +28,13 @@ android {
applicationId "de.seemoo.at_tracking_detection"
minSdkVersion 28
targetSdk = 34
versionCode 44
versionName "2.2"
versionCode 45
versionName "2.3"

buildConfigField "String", "API_KEY", apiProperties["API_KEY"]
buildConfigField "String", "API_BASE_ADDRESS", apiProperties["API_BASE_ADDRESS"]

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas")
}
}
}

buildTypes {
Expand All @@ -65,11 +61,6 @@ android {
jvmTarget = JavaVersion.VERSION_17.toString()
}

composeOptions {
kotlinCompilerExtensionVersion "1.5.11"
}


sourceSets {
// Adds exported schema location as test app assets.
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
Expand All @@ -95,31 +86,31 @@ dependencies {
implementation 'com.github.bastienpaulfr:Treessence:1.0.0'
implementation "androidx.work:work-runtime-ktx:$work_version"
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.vectordrawable:vectordrawable:1.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.7.7'
implementation 'androidx.navigation:navigation-ui-ktx:2.7.7'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.8.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.8.3'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.12'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.14'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.work:work-testing:$work_version"
implementation 'androidx.core:core-ktx:1.13.1'
debugImplementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.12'
debugImplementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.14'

implementation "com.google.dagger:hilt-android:$hilt_version"
implementation 'androidx.hilt:hilt-work:1.2.0'
implementation 'androidx.hilt:hilt-navigation-fragment:1.2.0'
implementation "com.google.dagger:hilt-android:$hilt_compiler_version"
implementation "androidx.hilt:hilt-work:$hilt_version"
implementation "androidx.hilt:hilt-navigation-fragment:$hilt_version"

implementation 'com.github.AppIntro:AppIntro:6.1.0'

Expand All @@ -134,23 +125,22 @@ dependencies {

implementation 'com.github.bumptech.glide:glide:4.16.0'


kapt "com.google.dagger:hilt-compiler:$hilt_version"
kapt 'androidx.hilt:hilt-compiler:1.2.0'
ksp "com.google.dagger:hilt-compiler:$hilt_compiler_version"
ksp "androidx.hilt:hilt-compiler:$hilt_version"

implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
ksp "androidx.room:room-compiler:$room_version"

androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation "androidx.room:room-testing:$room_version"
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.0'
androidTestImplementation 'androidx.test:core:1.5.0'
androidTestImplementation 'androidx.test:core-ktx:1.5.0'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.5.1'
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1'
androidTestImplementation 'androidx.test:core:1.6.1'
androidTestImplementation 'androidx.test:core-ktx:1.6.1'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.2.1'
androidTestImplementation 'androidx.test:runner:1.6.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.6.1'

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'

Expand All @@ -161,16 +151,19 @@ dependencies {
// Integration with activities
implementation 'androidx.activity:activity-compose:1.9.0'
// Compose Material Design
implementation 'androidx.compose.material:material:1.6.7'
implementation 'androidx.compose.material:material:1.6.8'
// Animations
implementation 'androidx.compose.animation:animation:1.6.7'
implementation 'androidx.compose.animation:animation:1.6.8'
// Tooling support (Previews, etc.)
implementation 'androidx.compose.ui:ui-tooling:1.6.7'
implementation 'androidx.compose.ui:ui-tooling:1.6.8'
// Integration with ViewModels
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3'
// UI Tests
androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.6.7'
androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.6.8'
// When using a MDC theme
implementation "com.google.android.material:compose-theme-adapter:1.2.1"
}

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class DevicesTabUITest {

//Disabling all devices
onView(withText("AirTag")).perform(click())
onView(withText("FindMy Device")).perform(click())
onView(withText("AppleFindMy Device")).perform(click())
onView(withText("AirPods")).perform(click())
onView(withText("Apple Device")).perform(click())
onView(withText("Galaxy SmartTag")).perform(click())
Expand All @@ -101,7 +101,7 @@ class DevicesTabUITest {

//Enabling all devices
onView(withText("AirTag")).perform(click())
onView(withText("FindMy Device")).perform(click())
onView(withText("AppleFindMy Device")).perform(click())
onView(withText("AirPods")).perform(click())
onView(withText("Apple Device")).perform(click())
onView(withText("Galaxy SmartTag")).perform(click())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,14 @@ data class BaseDevice(
DeviceType.UNKNOWN -> Unknown(deviceId)
DeviceType.APPLE -> AppleDevice(deviceId)
DeviceType.AIRPODS -> AirPods(deviceId)
DeviceType.FIND_MY -> FindMy(deviceId)
DeviceType.FIND_MY -> AppleFindMy(deviceId)
DeviceType.TILE -> Tile(deviceId)
DeviceType.CHIPOLO -> Chipolo(deviceId)
DeviceType.PEBBLEBEE -> PebbleBee(deviceId)
DeviceType.SAMSUNG -> SamsungDevice(deviceId)
DeviceType.GALAXY_SMART_TAG -> SmartTag(deviceId)
DeviceType.GALAXY_SMART_TAG_PLUS -> SmartTagPlus(deviceId)
DeviceType.GOOGLE_FIND_MY_NETWORK -> GoogleFindMyNetwork(deviceId)
else -> {
// For backwards compatibility
if (payloadData?.and(0x10)?.toInt() != 0 && connectable == true) {
Expand Down Expand Up @@ -145,13 +147,15 @@ data class BaseDevice(
return when (deviceType) {
DeviceType.TILE -> Tile.getConnectionState(scanResult)
DeviceType.CHIPOLO -> Chipolo.getConnectionState(scanResult)
DeviceType.PEBBLEBEE -> PebbleBee.getConnectionState(scanResult)
DeviceType.SAMSUNG,
DeviceType.GALAXY_SMART_TAG,
DeviceType.GALAXY_SMART_TAG_PLUS -> SamsungDevice.getConnectionState(scanResult)
DeviceType.AIRPODS,
DeviceType.FIND_MY,
DeviceType.AIRTAG,
DeviceType.APPLE -> AppleDevice.getConnectionState(scanResult)
DeviceType.GOOGLE_FIND_MY_NETWORK -> GoogleFindMyNetwork.getConnectionState(scanResult)
else -> ConnectionState.UNKNOWN
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import kotlin.experimental.and

object DeviceManager {

val devices = listOf(AirTag, FindMy, AirPods, AppleDevice, SmartTag, SmartTagPlus, Tile, Chipolo)
private val appleDevices = listOf(AirTag, FindMy, AirPods, AppleDevice)
val devices = listOf(AirTag, AppleFindMy, AirPods, AppleDevice, SmartTag, SmartTagPlus, Tile, Chipolo, PebbleBee, GoogleFindMyNetwork)
private val appleDevices = listOf(AirTag, AppleFindMy, AirPods, AppleDevice)
val unsafeConnectionState = listOf(ConnectionState.OVERMATURE_OFFLINE, ConnectionState.UNKNOWN)
val savedConnectionStates = unsafeConnectionState //enumValues<ConnectionState>().toList()

Expand All @@ -32,7 +32,7 @@ object DeviceManager {
}
}

fun getDeviceTypeFromCache(deviceAddress: String): DeviceType? {
private fun getDeviceTypeFromCache(deviceAddress: String): DeviceType? {
deviceTypeCache[deviceAddress]?.let { cachedDeviceType ->
return cachedDeviceType
}
Expand All @@ -56,10 +56,15 @@ object DeviceManager {
}
}

if (scanRecord.serviceData.contains(GoogleFindMyNetwork.offlineFindingServiceUUID)) {
return GoogleFindMyNetwork.deviceType
}

scanRecord.serviceUuids?.let { services ->
when {
services.contains(Tile.offlineFindingServiceUUID) -> return Tile.deviceType
services.contains(Chipolo.offlineFindingServiceUUID) -> return Chipolo.deviceType
services.contains(PebbleBee.offlineFindingServiceUUID) -> return PebbleBee.deviceType
services.contains(SmartTag.offlineFindingServiceUUID) -> return SamsungDevice.getSamsungDeviceType(scanResult)
else -> return Unknown.deviceType
}
Expand All @@ -75,11 +80,13 @@ object DeviceManager {
DeviceType.APPLE -> AppleDevice.websiteManufacturer
DeviceType.AIRPODS -> AirPods.websiteManufacturer
DeviceType.TILE -> Tile.websiteManufacturer
DeviceType.FIND_MY -> FindMy.websiteManufacturer
DeviceType.FIND_MY -> AppleFindMy.websiteManufacturer
DeviceType.CHIPOLO -> Chipolo.websiteManufacturer
DeviceType.PEBBLEBEE -> PebbleBee.websiteManufacturer
DeviceType.SAMSUNG -> SamsungDevice.websiteManufacturer
DeviceType.GALAXY_SMART_TAG -> SmartTag.websiteManufacturer
DeviceType.GALAXY_SMART_TAG_PLUS -> SmartTagPlus.websiteManufacturer
DeviceType.GOOGLE_FIND_MY_NETWORK -> GoogleFindMyNetwork.websiteManufacturer
}
}

Expand All @@ -91,7 +98,9 @@ object DeviceManager {
return DeviceType.valueOf(deviceTypeString)
}

val scanFilter: List<ScanFilter> = devices.map { it.bluetoothFilter }
val scanFilter: List<ScanFilter> = devices.map {
it.bluetoothFilter
}

val gattIntentFilter: IntentFilter = IntentFilter().apply {
addAction(BluetoothConstants.ACTION_EVENT_RUNNING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ enum class DeviceType {
TILE,
FIND_MY,
CHIPOLO,
PEBBLEBEE,
SAMSUNG,
GALAXY_SMART_TAG,
GALAXY_SMART_TAG_PLUS;
GALAXY_SMART_TAG_PLUS,
GOOGLE_FIND_MY_NETWORK;

companion object {
fun userReadableName(deviceType: DeviceType): String {
Expand All @@ -23,12 +25,14 @@ enum class DeviceType {
AIRPODS -> AirPods.defaultDeviceName
AIRTAG -> AirTag.defaultDeviceName
APPLE -> AppleDevice.defaultDeviceName
FIND_MY -> FindMy.defaultDeviceName
FIND_MY -> AppleFindMy.defaultDeviceName
TILE -> Tile.defaultDeviceName
PEBBLEBEE -> PebbleBee.defaultDeviceName
CHIPOLO -> Chipolo.defaultDeviceName
SAMSUNG -> SamsungDevice.defaultDeviceName
GALAXY_SMART_TAG -> SmartTag.defaultDeviceName
GALAXY_SMART_TAG_PLUS -> SmartTagPlus.defaultDeviceName
GOOGLE_FIND_MY_NETWORK -> GoogleFindMyNetwork.defaultDeviceName
}
}

Expand All @@ -41,9 +45,11 @@ enum class DeviceType {
FIND_MY -> R.drawable.ic_chipolo
TILE -> R.drawable.ic_tile
CHIPOLO -> R.drawable.ic_chipolo
PEBBLEBEE -> R.drawable.ic_baseline_device_unknown_24
SAMSUNG -> R.drawable.ic_baseline_device_unknown_24
GALAXY_SMART_TAG -> R.drawable.ic_smarttag_icon
GALAXY_SMART_TAG_PLUS -> R.drawable.ic_smarttag_icon
GOOGLE_FIND_MY_NETWORK -> R.drawable.ic_chipolo
}
}

Expand All @@ -64,6 +70,8 @@ enum class DeviceType {
allowedDeviceTypes.add(GALAXY_SMART_TAG_PLUS)
}
"tiles" -> allowedDeviceTypes.add(TILE)
"pebblebees" -> allowedDeviceTypes.add(PEBBLEBEE)
"google_find_my_network" -> allowedDeviceTypes.add(GOOGLE_FIND_MY_NETWORK)
}
}

Expand All @@ -77,6 +85,7 @@ enum class DeviceType {
return when (this) {
TILE -> true
CHIPOLO -> true
PEBBLEBEE -> true
else -> false
}
}
Expand All @@ -85,59 +94,67 @@ enum class DeviceType {
return when (this) {
TILE -> Tile.numberOfHoursToBeConsideredForTrackingDetection
CHIPOLO -> Chipolo.numberOfHoursToBeConsideredForTrackingDetection
PEBBLEBEE -> PebbleBee.numberOfHoursToBeConsideredForTrackingDetection
UNKNOWN -> Unknown.numberOfHoursToBeConsideredForTrackingDetection
AIRPODS -> AirPods.numberOfHoursToBeConsideredForTrackingDetection
AIRTAG -> AirTag.numberOfHoursToBeConsideredForTrackingDetection
APPLE -> AppleDevice.numberOfHoursToBeConsideredForTrackingDetection
FIND_MY -> FindMy.numberOfHoursToBeConsideredForTrackingDetection
FIND_MY -> AppleFindMy.numberOfHoursToBeConsideredForTrackingDetection
SAMSUNG -> SamsungDevice.numberOfHoursToBeConsideredForTrackingDetection
GALAXY_SMART_TAG -> SmartTag.numberOfHoursToBeConsideredForTrackingDetection
GALAXY_SMART_TAG_PLUS -> SmartTagPlus.numberOfHoursToBeConsideredForTrackingDetection
GOOGLE_FIND_MY_NETWORK -> GoogleFindMyNetwork.numberOfHoursToBeConsideredForTrackingDetection
}
}

fun getNumberOfLocationsToBeConsideredForTrackingDetectionLow(): Int {
return when (this) {
TILE -> Tile.numberOfLocationsToBeConsideredForTrackingDetectionLow
CHIPOLO -> Chipolo.numberOfLocationsToBeConsideredForTrackingDetectionLow
PEBBLEBEE -> PebbleBee.numberOfLocationsToBeConsideredForTrackingDetectionLow
UNKNOWN -> Unknown.numberOfLocationsToBeConsideredForTrackingDetectionLow
AIRPODS -> AirPods.numberOfLocationsToBeConsideredForTrackingDetectionLow
AIRTAG -> AirTag.numberOfLocationsToBeConsideredForTrackingDetectionLow
APPLE -> AppleDevice.numberOfLocationsToBeConsideredForTrackingDetectionLow
FIND_MY -> FindMy.numberOfLocationsToBeConsideredForTrackingDetectionLow
FIND_MY -> AppleFindMy.numberOfLocationsToBeConsideredForTrackingDetectionLow
SAMSUNG -> SamsungDevice.numberOfLocationsToBeConsideredForTrackingDetectionLow
GALAXY_SMART_TAG -> SmartTag.numberOfLocationsToBeConsideredForTrackingDetectionLow
GALAXY_SMART_TAG_PLUS -> SmartTagPlus.numberOfLocationsToBeConsideredForTrackingDetectionLow
GOOGLE_FIND_MY_NETWORK -> GoogleFindMyNetwork.numberOfLocationsToBeConsideredForTrackingDetectionLow
}
}

fun getNumberOfLocationsToBeConsideredForTrackingDetectionMedium(): Int {
return when (this) {
TILE -> Tile.numberOfLocationsToBeConsideredForTrackingDetectionMedium
CHIPOLO -> Chipolo.numberOfLocationsToBeConsideredForTrackingDetectionMedium
PEBBLEBEE -> PebbleBee.numberOfLocationsToBeConsideredForTrackingDetectionMedium
UNKNOWN -> Unknown.numberOfLocationsToBeConsideredForTrackingDetectionMedium
AIRPODS -> AirPods.numberOfLocationsToBeConsideredForTrackingDetectionMedium
AIRTAG -> AirTag.numberOfLocationsToBeConsideredForTrackingDetectionMedium
APPLE -> AppleDevice.numberOfLocationsToBeConsideredForTrackingDetectionMedium
FIND_MY -> FindMy.numberOfLocationsToBeConsideredForTrackingDetectionMedium
FIND_MY -> AppleFindMy.numberOfLocationsToBeConsideredForTrackingDetectionMedium
SAMSUNG -> SamsungDevice.numberOfLocationsToBeConsideredForTrackingDetectionMedium
GALAXY_SMART_TAG -> SmartTag.numberOfLocationsToBeConsideredForTrackingDetectionMedium
GALAXY_SMART_TAG_PLUS -> SmartTagPlus.numberOfLocationsToBeConsideredForTrackingDetectionMedium
GOOGLE_FIND_MY_NETWORK -> GoogleFindMyNetwork.numberOfLocationsToBeConsideredForTrackingDetectionMedium
}
}

fun getNumberOfLocationsToBeConsideredForTrackingDetectionHigh(): Int {
return when (this) {
TILE -> Tile.numberOfLocationsToBeConsideredForTrackingDetectionHigh
CHIPOLO -> Chipolo.numberOfLocationsToBeConsideredForTrackingDetectionHigh
PEBBLEBEE -> PebbleBee.numberOfLocationsToBeConsideredForTrackingDetectionHigh
UNKNOWN -> Unknown.numberOfLocationsToBeConsideredForTrackingDetectionHigh
AIRPODS -> AirPods.numberOfLocationsToBeConsideredForTrackingDetectionHigh
AIRTAG -> AirTag.numberOfLocationsToBeConsideredForTrackingDetectionHigh
APPLE -> AppleDevice.numberOfLocationsToBeConsideredForTrackingDetectionHigh
FIND_MY -> FindMy.numberOfLocationsToBeConsideredForTrackingDetectionHigh
FIND_MY -> AppleFindMy.numberOfLocationsToBeConsideredForTrackingDetectionHigh
SAMSUNG -> SamsungDevice.numberOfLocationsToBeConsideredForTrackingDetectionHigh
GALAXY_SMART_TAG -> SmartTag.numberOfLocationsToBeConsideredForTrackingDetectionHigh
GALAXY_SMART_TAG_PLUS -> SmartTagPlus.numberOfLocationsToBeConsideredForTrackingDetectionHigh
GOOGLE_FIND_MY_NETWORK -> GoogleFindMyNetwork.numberOfLocationsToBeConsideredForTrackingDetectionHigh
}
}
}
Loading

0 comments on commit 4224196

Please sign in to comment.