Skip to content

Commit

Permalink
support Motorola Moto Tag Name Detection and Owner Device Retrieval E…
Browse files Browse the repository at this point in the history
…xplanation
  • Loading branch information
imbissbudenaesthetik committed Jan 17, 2025
1 parent 2ba7810 commit 4f9e756
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ class GoogleFindMyNetwork(val id: Int) : Device(), Connectable {

fun getSubType(wrappedScanResult: ScanResultWrapper): GoogleFindMyNetworkType {
return when (wrappedScanResult.advertisementFlags) {
0x02 -> GoogleFindMyNetworkType.SMARTPHONE
0x06 -> GoogleFindMyNetworkType.TAG
else -> GoogleFindMyNetworkType.UNKNOWN
0x02 -> SMARTPHONE
0x06 -> TAG
else -> UNKNOWN
}
}

Expand All @@ -234,9 +234,9 @@ class GoogleFindMyNetwork(val id: Int) : Device(), Connectable {
// If receivedValue is not empty, return the device name, else fallback to error case
receivedValue?.let {
val nameBytes = it.drop(2).toByteArray() // Drop the first two bytes
val finalResult = String(nameBytes, Charsets.UTF_8)
ScanFragment.deviceNameMap[wrappedScanResult.uniqueIdentifier] = finalResult
finalResult
val decodedBytes = String(nameBytes, Charsets.UTF_8)
ScanFragment.deviceNameMap[wrappedScanResult.uniqueIdentifier] = decodedBytes
nameReplacementLayer(decodedBytes)
} ?: errorCaseName
} catch (e: Exception) {
Timber.e("Error during connectAndWrite: ${e.message}")
Expand Down Expand Up @@ -401,13 +401,21 @@ class GoogleFindMyNetwork(val id: Int) : Device(), Connectable {
return ConnectionState.UNKNOWN
}

fun nameReplacementLayer(name: String): String {
return when {
name.contains("motorola", ignoreCase = true) -> "Motorola Moto Tag"
else -> name
}
}

fun getGoogleManufacturerFromNameString(name: String): GoogleFindMyNetworkManufacturer {
Timber.d("Name: $name")
return when {
name.contains("pebblebee", ignoreCase = true) -> GoogleFindMyNetworkManufacturer.PEBBLEBEE
name.contains("chipolo", ignoreCase = true) -> GoogleFindMyNetworkManufacturer.CHIPOLO
name.contains("eufy", ignoreCase = true) -> GoogleFindMyNetworkManufacturer.EUFY
name.contains("motorola", ignoreCase = true) -> GoogleFindMyNetworkManufacturer.MOTOROLA
name.contains("moto", ignoreCase = true) -> GoogleFindMyNetworkManufacturer.MOTOROLA
name.contains("eufy", ignoreCase = true) -> GoogleFindMyNetworkManufacturer.EUFY
name.contains("jio", ignoreCase = true) -> GoogleFindMyNetworkManufacturer.JIO
name.contains("rolling square", ignoreCase = true) -> GoogleFindMyNetworkManufacturer.ROLLING_SQUARE
else -> GoogleFindMyNetworkManufacturer.UNKNOWN
Expand All @@ -427,6 +435,7 @@ class GoogleFindMyNetwork(val id: Int) : Device(), Connectable {
return when (manufacturer) {
GoogleFindMyNetworkManufacturer.PEBBLEBEE -> ATTrackingDetectionApplication.getAppContext().resources.getString(R.string.retrieve_owner_information_explanation_pebblebee)
GoogleFindMyNetworkManufacturer.CHIPOLO -> ATTrackingDetectionApplication.getAppContext().resources.getString(R.string.retrieve_owner_information_explanation_chipolo)
GoogleFindMyNetworkManufacturer.MOTOROLA -> ATTrackingDetectionApplication.getAppContext().resources.getString(R.string.retrieve_owner_information_explanation_motorola)
else -> ATTrackingDetectionApplication.getAppContext().resources.getString(R.string.retrieve_owner_information_explanation_unknown)
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@
<string name="retrieve_owner_information_explanation_unknown">Um Informationen zum Besitzer des Trackers zu erhalten musst du den Tracker gefunden und physisch vor dir haben. Wenn du den Tracker gefunden hast, musst du ihn in einem speziellen Modus versetzen. Wie dieser Modus erreicht wird ist unterschiedlich und könnte durch 30 Sekunden den Button drücken oder dreimal den Button drücken geschehen. Der Modus wird durch ein piepsen bestätigt. Danach drücke auf \"weiter\".</string>
<string name="retrieve_owner_information_explanation_pebblebee">Um Informationen zum Besitzer des Trackers zu erhalten musst du den Tracker gefunden und physisch vor dir haben. Wenn du den Tracker gefunden hast, dann drücke den Knopf auf dem Tracker dreimal. Dies sollte durch ein piepsen bestätigt werden. Danach drücke auf \"weiter\".</string>
<string name="retrieve_owner_information_explanation_chipolo">Um Informationen zum Besitzer des Trackers zu erhalten musst du den Tracker gefunden und physisch vor dir haben. Wenn du den Tracker gefunden hast, dann halten den Knopf für 30 Sekunden gedrückt. Lasse den Knopf exakt nach dem zweiten piepsen los. Dies wird durch einen weiteren Ton bestätigt. Danach drücke auf \"weiter\".</string>
<string name="retrieve_owner_information_explanation_motorola">Um Informationen zum Besitzer des Trackers zu erhalten musst du den Tracker gefunden und physisch vor dir haben. Wenn du den Tracker gefunden hast, halte den Button für 10 Sekunden gedrückt, bis ein Piepton ertönt. Lasse den Button dann los, drücke ihn erneut, und lasse sofort wieder los. Danach drücke auf \"weiter\".</string>
<string name="retrieve_owner_information_alert_next">Weiter</string>
<string name="retrieve_owner_information_alert_close">Beenden</string>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@
<string name="retrieve_owner_information_explanation_unknown">To get information about the owner you have to physically have found the Tracker. Once you have found it you have to get it in a special mode. This can be something like pressing the button three times or holding the button for 30 seconds. If successful this will be confirmed by a sound. Afterwards press \"next\".</string>
<string name="retrieve_owner_information_explanation_pebblebee">To get information about the owner you have to physically have found the Tracker. Once you have found it press the button on the tracker three times. This will be confirmed by a sound. Afterwards press \"next\".</string>
<string name="retrieve_owner_information_explanation_chipolo">To get information about the owner you have to physically have found the Tracker. Once you have found it press the button on the tracker for 30 seconds and release the button exactly after the second beep. This will be confirmed by a sound indicating success. Afterwards press \"next\".</string>
<string name="retrieve_owner_information_explanation_motorola">To get information about the owner you have to physically have found the Tracker. Once you have found it press and hold the button for 10 seconds until you hear a beep. Afterward, release the button and press &amp; release again immediately. Afterwards press \"next\".</string>
<string name="retrieve_owner_information_alert_next">Next</string>
<string name="retrieve_owner_information_alert_close">Close</string>

Expand Down

0 comments on commit 4f9e756

Please sign in to comment.